gnarpeggio
Registered User.
- Local time
- Today, 00:00
- Joined
- Jun 22, 2010
- Messages
- 74
Hello,
I'm working on a feature I'd like to include in my database that utilizes the IsLoaded property to check for an open form and complete an action depeding on which form is currently open.
I have two forms, both of which can pull Party Information from a Parties table. My problem has been getting the DB to tell the truth and correctly run the If statement I built when the form IsLoaded.
When entering a new record, users can choose a previously entered party by opening the Parties form and clicking the Select Party cmd button. Once the party is selected, my If statement will determine which form is open (IsLoaded) and runs an update query that adds the Party ID to the new record on the table of the open form.
Here is what my code is looking like at the moment:
This code is built on the Select Party command button on my Parties form. It’s supposed to 1) check if the “frm_Batch_Deposit_WR” form is open, if True then run BatchSQL. If False, move onto ElseIf AcctOpen. If True run AcctSQL, if False go to next line and check if both are open. If True, produce MsgBox warning.
Any help on resolving this issue would be greatly appreciated.
Thanks!
I'm working on a feature I'd like to include in my database that utilizes the IsLoaded property to check for an open form and complete an action depeding on which form is currently open.
I have two forms, both of which can pull Party Information from a Parties table. My problem has been getting the DB to tell the truth and correctly run the If statement I built when the form IsLoaded.
When entering a new record, users can choose a previously entered party by opening the Parties form and clicking the Select Party cmd button. Once the party is selected, my If statement will determine which form is open (IsLoaded) and runs an update query that adds the Party ID to the new record on the table of the open form.
Here is what my code is looking like at the moment:
Private Sub cmdSend_Data_Click()
On Error GoTo Err_cmdSend_Data_Click
Dim BatchSQL As String
Dim AcctSQL As String
Dim WROpen As String
Dim AcctOpen As String
AcctSQL = "UPDATE tbl_frm_Single_Payment_Acct SET tbl_frm_Single_Payment_Acct.Party_ID = tbl_Parties.Party_ID WHERE tbl_Single_Payment_Acct= " & Forms!frm_Single_Payment_Acct.Item_ID
BatchSQL = "UPDATE tbl_WR_Batch_Deposits SET tbl_WR_Batch_Deposits.Party_ID = tbl_Parties.Party_ID WHERE tbl_WR_Batch_Deposits.Item_ID= " & Forms!frm_Batch_Deposit_WR.Item_ID
WROpen = CurrentProject.AllForms("frm_Batch_Deposit_WR").IsLoaded
AcctOpen = CurrentProject.AllForms("frm_Single_Payment_Acct").IsLoaded
If WROpen = True Then
DoCmd.RunSQL BatchSQL
ElseIf AcctOpen = True Then
DoCmd.RunSQL AcctSQL
ElseIf WROpen And AcctOpen = True Then
MsgBox "Please close one of the forms to continue"
Else
Exit Sub
End If
Exit_cmdSend_Data_Click:
Exit Sub
Err_cmdSend_Data_Click:
Select Case Err
Case 2450
MsgBox "You must have one of the following forms open to select a party:" & vbNewLine & vbNewLine & "Single Payments - Accounting" & vbNewLine _
& vbNewLine & "Batch Deposits", 7
DoCmd.Hourglass False
Resume Exit_cmdSend_Data_Click
End Select
End Sub
This code is built on the Select Party command button on my Parties form. It’s supposed to 1) check if the “frm_Batch_Deposit_WR” form is open, if True then run BatchSQL. If False, move onto ElseIf AcctOpen. If True run AcctSQL, if False go to next line and check if both are open. If True, produce MsgBox warning.
Any help on resolving this issue would be greatly appreciated.
Thanks!