Forum Replies Created
-
AuthorReplies
-
Not a problem, I completely understand. Hope you have a Merry Christmas and look forward to your suggestions in the New Year.
Hello Support,
Please disregard my request below, I figured out the problem.
You have been very helpful as usual and I am much further with my form processing and I thank you. I have one minor issue and have attached the code for you to look at. It is in the update logic, the record’s old value is not being kept, can you tell me why?
‘——————————————————————————-
‘ Insert your comments here
‘——————————————————————————-Sub Main(Client, GWEvent)
dim oADOObjset oADOObj = nothing
‘ if not OpenDataBase(oADOObj) then
‘ exit sub
‘end ifMenu.showmodal
‘CloseDataBase(oADOObj)
set oADOObj = nothingEnd Sub
‘ Open Database connection
function OpenDataBase(byref aADOObj)
‘ << Setup your connection string and other process relate to opening database >>
OpenDataBase = false
Set aADOObj = CreateObject(“ADODB.Connection”)
if isobject(aADOObj) then
iConnnectString = “Driver={MySQL ODBC 3.51 Driver}; Data Source=Formativ”
aADOObj.Open iConnnectString
if err.number = 0 then
OpenDataBase = true
msgbox “Database is open”
else
call msgbox(“Failed to create ADODB.Connection object.”, vbCritical, CAPTION)
end if
end if
end function‘ Close Database connection
function CloseDataBase(byref aADOObj)
if aADOObj is nothing then
exit function
end if
aADOObj.close
end functionfunction clear_form
FRM1.Name_data.text = “”
FRM1.ModalResult = MROK
end function‘ Add record as the connection is already opened so no need to open in here
Sub AddNewRecord(byref aADOObj)
dim iSQLstring
dim iName, iRST, iUseridif aADOObj is nothing then ‘** error Object required
exit sub
end ifiName = FRM1.Name_data.text
iUserid = groupwise.EnvUserID
iSQLString = “Insert into children (name, userid) values (‘” & iName & “‘,'” & iUserid & “‘)”
Set iRST = aADOObj.Execute(iSQLString)
Set iRST = Nothing
end subSub TestButton2Click(Sender)
FRM1.Showmodal
End SubSub NameButton1Click(Sender)
if FRM1.NameButton1.Caption = “Update Record” then
call UpdateExistingRecordDialog(iADOObj, old_name)
Clear_form
exit sub
end if
if not OpenDataBase(oADOObj) then
exit sub
end if
AddNewRecord(oADOObj)
Clear_form
CloseDataBase(OADOObj)
End Subsub StoreExistingRecordsDialog(byref iADOObj, byref iUpdateDlg, byref iListBox)
dim iRSTset iUpdateDlg = Utilities.NewControlBoxDialog
with iUpdateDlg
.Caption = CAPTION
.Title = “Existing records”
.Description = HRT & “Select an existing record to update”
end withset iListBox = iUpdateDlg.AddListBoxControl
iListBox.Caption = “Records:”iSQLString = “SELECT * FROM Children”
Set iRST = iADOObj.Execute(iSQLString)Do Until (iRST.EOF)
iListBox.items.add(iRST(“Name”))
iRST.MoveNext
LoopiRST.Close
Set iRST = Nothingend sub
‘***** Problem area ****
‘aExtName is empty’sub UpdateExistingRecordDialog(byref iADOObj, aExtName)
dim iNameUpdate, INameOld
iNameUpdate = FRM1.Name_data.text
iNameOld = aExtName
‘ If we press the Ol button to update
‘ iSQLUpdate = “UPDATE SET Name ='” & Name.Text & “‘ WHERE Name ='” & aExtName & “‘”
‘ Set iRST = iADOObj.Execute(iSQLUpdate)
msgbox iNameOld
msgbox iNameUpdate
call msgbox (“record updated.”, vbInformation, CAPTION)
end subHope you have a great weekend.
sub EditRecord(byref iADOObj)
dim iUpdateDlg
dim iListBox
dim iNameSelectedcExit = 999
cEditRecord = 201
cDisplayAllRecords = 101
Cmd = cDisplayAllRecordscall StoreExistingRecordsDialog(iADOObj, iUpdateDlg, iListBox)
do while Cmd <> cExit
if Cmd = cDisplayAllRecords then
select case iUpdateDlg.execute
case Btn1 Cmd = cEditRecord
case else Cmd = cExit
end select
end ifif Cmd = cEditRecord then
if iListBox.Selected <> “” then
iNameSelected = iListBox.Selected
FRM1.Name_data.text = iNameSelected
FRM1.NameButton1.Caption = “Update Record”
FRM1.Showmodal
Cmd = cExit
else
call msgbox (“Select a record to update.”, vbInformation, CAPTION)
Cmd = cDisplayAllRecords
end if
end if
loopend sub
Sub MenuButton1Click(Sender)
if not OpenDataBase(oADOObj) then
exit sub
end if
EditRecord(oADOObj)
CloseDataBase(OADOObj)
End SubSub name_dataEnter(Sender)
dim old_name
old_name = FRM1.Name_data.text
msgbox old_name ‘ data is in this field
End SubI have tried what you have suggested and get an error stating the following:
Formativ Applet runtime error
G:AdvansysFormativAppletsCDIP Monthly Activities.vbf
Object doesn’t support this property or method: ‘iDlg.ModalResult’ at line 206, column 3I have attached the code for you to look at just incase I did not explain myself properly.
Thanks in advance for your continued support.‘——————————————————————————-
‘ Insert your comments here
‘——————————————————————————-
Dim iDlg
HRT = Chr(13) & Chr(10)
const CAPTION = “Chronic Disease and Injury Prevention Reporting Solutions”
logo = Utilities.GetDataDirectory & “logo.gif”Sub Main(Client, GWEvent)
dim I
dim iGuidelines, iGuideline
dim oItem
IntroDlg
select case iDlg.execute
case Btn1 AddNewRecord
case Btn3 DisplayAllRecords(iADOObj)
case Btn4 FindRecord(iADOObj)
case Btn5 EditRecord(iADOObj)
end select
End Sub‘——————————————————————————-
Sub AddNewRecord
CDIP_FRM.showmodal
end subFunction IntroDlg
set iDlg = Utilities.NewControlBoxDialog
with iDlg
.Caption = CAPTION
.Height = 550
.ShowWizardImage = False
.Title = “CDIP Monthly Activities Reporting Management”
.Button1Caption = “&Add”
.Button3Visible = True
.Button3Caption = “&Display All”
.Button4Visible = True
.Button4Caption = “&Find Record”
.Button5Visible = TRUE
.Button5Caption = “&Update”
.Description = HRT & “This applet will allow you to add a new record, display ” &_
“all records or find a record in the database.” & HRT & HRT
end with
set ImageCtl = iDlg.AddImageControl
with ImageCtl
.ImageFile = ” C:Program FilesAdvansysFormativimageslogo.gif”
.center = TRUE
.stretch = true
end with
End FunctionSub setcalendar(Sender)
CDIP_FRM.MonthEdit.date = now
End SubSub Clear_form
dim a_cnt
CDIP_FRM.MonthEdit.date = now
CDIP_FRM.Geographic_Area.ItemIndex = -1
CDIP_FRM.Topic.ItemIndex = -1
CDIP_FRM.Channel.itemindex = -1
CDIP_FRM.Method.itemindex = -1
CDIP_FRM.Target.itemindex = -1
CDIP_FRM.keymessage.text = “”
CDIP_FRM.Number_Reached.text = “”with CDIP_FRM.ListView.Items
for I = 0 to .Count – 1
if .Item(I).Selected then
CDIP_FRM.ListView.itemindex = -1
end if
next
end with
End SubSub Add_Record
dim iRST
dim t_cnt
dim iUserid
dim iMonth
dim iYear
dim iArea
dim iTopic
dim iChannel
dim iMethod
dim iTarget
dim iReached
dim iKeymsg
dim i_Guideline_area
dim i_Guideline_num
dim i_Guideline
dim Icall msgbox(“Adding Record”)
iUserid = groupwise.EnvUserID
iKeymsg = CDIP_FRM.keymessage.text
iYear = Year(CDIP_FRM.MonthEdit.Date)
iMonth = Month(CDIP_FRM.MonthEdit.Date)
iChannel = CDIP_FRM.Channel.text
iMethod = CDIP_FRM.Method.text
iTarget = CDIP_FRM.Target.text
iReached = CDIP_FRM.Number_Reached.textIf CDIP_FRM.Geographic_Area.ItemIndex > -1 Then
aidx = CDIP_FRM.Geographic_Area.ItemIndex
iArea = CDIP_FRM.Geographic_Area.items(aidx)
End ifIf CDIP_FRM.Topic.ItemIndex > -1 Then
tidx = CDIP_FRM.Topic.ItemIndex
iTopic = CDIP_FRM.Topic.items(tidx)
End ifwith CDIP_FRM.ListView.Items
for I = 0 to .Count – 1
if .Item(I).Selected then
iGuideline_area = iGuideline_area & vbnewline & .Item(I).Caption
iGuideline_num = iGuideline_num & vbnewline &.Item(I).SubItems(0)
iGuideline = iGuideline & vbnewline &.Item(I).SubItems(1)
end if
next
end withSet iADOObj = CreateObject(“ADODB.Connection”)
if isobject(iADOObj) then‘ open the test data source with the Connection object
iConnnectString = “Driver={MySQL ODBC 3.51 Driver}; Data Source=CDIP_Connect”
iADOObj.Open iConnnectString‘ Are we connected?
if err.number = 0 then
iSQLString = “Insert into activities_dtl (month, year, area, topic, channel, method, target, num_reached, key_message, guideline_area, guideline_num , guideline, userid) values (‘” & iMonth & “‘,'” & iYear & “‘,'” & iArea & “‘,'” & iTopic & “‘,'” & iChannel & “‘,'” & iMethod & “‘,'” & iTarget & “‘,'” & iReached & “‘,'” & iKeymsg & “‘,'” & iGuideline_area & “‘,'” & iGuideline_num & “‘,'” & iGuideline & “‘,'” & iUserid & “‘” & “)”‘ ISQLString = “INSERT INTO activities_dtl(month, year, area, topic, channel, method, userid values(‘” & iMonth & “‘,'” & iYear & “‘,'” & iArea & “‘,'” & iTopic & “‘,'” & iChannel & “‘,'” & iMethod & “‘,'” & iUserid & “‘” & “)”
‘Msgbox iSQLString
Set iRST = iADOObj.Execute(iSQLString)
iADOobj.Close
Set iRST = Nothing
end if
else
call msgbox(“Failed to create ADODB.Connection object.”, vbCritical, CAPTION)
end if
Set iADOObj = Nothing
End SubSub SubmitBtnClick(Sender)
dim x, SearchString, SearchChar, MyPosif CDIP_FRM.Geographic_Area.ItemIndex = -1 then
msgbox(“Please select a geographic area from the radio group”)
CDIP_FRM.SubmitBtn.ModalResult = MRNONE
exit sub
end ifif CDIP_FRM.Topic.ItemIndex = -1 then
msgbox(“Please select a topic from the radio group”)
CDIP_FRM.SubmitBtn.ModalResult = MRNONE
exit sub
end ifif CDIP_FRM.Channel.ItemIndex = -1 then
msgbox(“Please select the channel used, click on the down arrow for valid selections.”)
CDIP_FRM.SubmitBtn.ModalResult = MRNONE
exit sub
end ifif CDIP_FRM.Method.ItemIndex = -1 then
msgbox(“Please select the method used, click on the down arrow for valid selections.”)
CDIP_FRM.SubmitBtn.ModalResult = MRNONE
exit sub
end ifif CDIP_FRM.Target.ItemIndex = -1 then
msgbox(“Please select the target audience, click on the down arrow for valid selections.”)
CDIP_FRM.SubmitBtn.ModalResult = MRNONE
exit sub
end ifSearchString = CDIP_FRM.Method.Text ‘ String to search in.
SearchChar = “Media Campaign” ‘ Search for “P”.
MyPos = Instr(1, SearchString, SearchChar, 1)if (MyPos > 0 and CDIP_FRM.keymessage.Text = “”) then
msgbox (“You must enter the key message when using a Media Campaign method”)
CDIP_FRM.SubmitBtn.ModalResult = MRNONE
end ifif (CDIP_FRM.ListView.itemindex < 0) then
msgbox(“Select the applicable guideline from the list to proceed.”)
CDIP_FRM.ListView.setfocus
CDIP_FRM.SubmitBtn.ModalResult = MRNONE
exit sub
end ifAdd_Record
myvar = Msgbox (“Do you wish to add another record?”,vbYesNo )
if myvar = vbYes then
Clear_form
end if
if myvar = vbNo then
CDIP_FRM.ModalResult = MROK
end if
iDlg.ModalResult = MRNONE
End SubSub CancelClick(Sender)
exitvar = Msgbox (“Exit without saving changes?”,vbYesNo )
if exitvar = vbYes then
CDIP_FRM.CANCEL.ModalResult = MRCANCEL
end ifif exitvar = vbNo then
CDIP_FRM.ModalResult = MRNONE
end if
End SubThank you for your help. Using this same example, if I would like to prompt the user if they would like to add another record, would this be done using another form? I would like the data entry from be closed, the user prompted to add another record, if yes then show the form again, if not return to groupwise. I do not want many versions of the data entry for open.
Much appreciated!
Thank you both for how to obtain the user information. I will be trying that out and let you know how I make out.
As for the vertical scroll bars I want them to be available at runtime when a form is launched. The reason is that the resolution I am developing at is not used by all staff. Or is there a way to have formativ dynamically resize according to screen resolution.
Hi,
First of all thank you for responding to my query. I am sorry it has taken me so long to reply to your coding suggestions. In the routing message dialog as you suggested I am using the attachment collection.
Code:
Using TOpenFileDialog I obtain the filename
Set NewMsg = GroupWise.Account.MailBox.Messages.Add
call NewMsg.Attachments.Add(WSFORM.Attachments.FileName, egwFile,””)I am successful in sending a single file only, I am not certain as to why I cannot send multiple files however, I first need to be able to see the file attachment I am sending in the routing mail message example.
The function I defined in the Routing Mail Message Example is shown below:
Function DisplayAttach
dim oMsg
set oMsg = Client.ClientState.CommandMessage
for each attachment in oMsg.Attachments
msgbox oMsg.Attachments.FileName
nextset oMsg = nothing
End Function
I have tried defining a button in the routing mail message intro dialog and associating it to the function but with no success. I have tried just calling the function with no success. The first step is to get the message box to appear with the file name but ultimately I would like to view the attachments within a routed mail message and send the files onto the next recipient, or for a newbie this is far to complex? I have read the suggested readings for Object API and it is very obvious that I have missed something BIG!
Hopefully this makes sense and I appreciate your help and time on this matter.
-
AuthorReplies