/ Forums / Advansys Formativ / Creating Solutions with Formativ / Modual Results
-
CreatorTopic
-
October 18, 2006 at 11:59 am #4298
Hello all
I have coded a Introdlg with 3 buttons, add, find and update. When the use clicks the add button, the form launches, and writes the record sucessfully however both the form and the dialog closes, is there a way of keeping the dialog infocus, so if the user chooses to find records they aren’t launching the applet again.
I know I am missing something probably very simple but I do appreciate the help.
Thanks
-
CreatorTopic
-
AuthorReplies
-
October 18, 2006 at 5:00 pm #7758
Select the button in Formativ Form Designer, change the ModalResult value to mrNone. Alternatively, you can set the dialog ModalResult in the applet:
‘Close the dialog when ‘Add’ button pressed
Sub btnAddClick(Sender)
MainDlg.modalresult = MROK
End Sub‘Do not close the dialog when ‘Add’ button pressed
Sub btnAddClick(Sender)
MainDlg.modalresult = MRNONE
End SubHope this helps.
Advansys Support
October 19, 2006 at 10:24 am #7760I 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 SubOctober 19, 2006 at 4:59 pm #7759Which version of Formativ framework are you running (See Help – About Formativ)?
Formativ 1.6 only shows modal dialog which has to be closed to continue other process including showing another dialog. In your case, you need to re-display the main dialog once the secondary dialog closed.
Formativ 2.0 allow you to build custom forms and dialogs using the dynamic visual forms designer and you can display secondary dialog while the main dialog is visible. The earlier response was based on Formativ 2 framework. See the web link below for more information about creating solution with Formativ 2:
http://www.advansyscorp.com/formativ_development_more.htmIf you are using Formativ Framework 2.0 then we highly recommend you to use the Formativ 2 Forms. See the ‘Formativ Users Guide’ for more information about creating, displaying Forms. Please do not hesitate to contact us if you have any further questions or comments.
Regards,
Advansys Support -
AuthorReplies
- You must be logged in to reply to this topic.