Hi all,
I'm working some code for the first time, and need a little backup here. I've got a form where I'd like to run a procedure after the user clicks a command button. The procedure checks two queries to see if the data entered meets two distinct criteria. The code craps out after opening the first query. Any help would be appreciated.
Thanks,
Cram
Sub tst()
Set db = CurrentDb()
Dim Criteria1 As Variant, Criteria2 As Variant
'Opens query for first criteria
DoCmd.OpenQuery "FLTUsed4", acViewNormal
DoCmd.GoToRecord acDataQuery, "FLTUsed4", acLast
Set Criteria1 = FLTUsed4.CountOfAuthor_Calc2.Value
If Criteria1 > 0 Then
DoCmd.Close acQuery, "FLTUsed4", acSaveNo
DoCmd.OpenForm "RefusalForm"
Else
DoCmd.Close acQuery, "FLTUsed4", acSaveNo
DoCmd.OpenQuery "LRQ3", acViewNormal
If LRQ3.CountofAuthorCalc2 > 0 Then
DoCmd.Close acQuery, "LRQ3", acSaveNo
DoCmd.OpenForm "RefusalForm2"
Else
DoCmd.Close acQuery, "LRQ3", acSaveNo
DoCmd.Close acForm, "PanelReservationForm", acSaveYes
DoCmd.OpenForm "ApprovalForm2"
End If
End If
End Sub
I'm working some code for the first time, and need a little backup here. I've got a form where I'd like to run a procedure after the user clicks a command button. The procedure checks two queries to see if the data entered meets two distinct criteria. The code craps out after opening the first query. Any help would be appreciated.
Thanks,
Cram
Sub tst()
Set db = CurrentDb()
Dim Criteria1 As Variant, Criteria2 As Variant
'Opens query for first criteria
DoCmd.OpenQuery "FLTUsed4", acViewNormal
DoCmd.GoToRecord acDataQuery, "FLTUsed4", acLast
Set Criteria1 = FLTUsed4.CountOfAuthor_Calc2.Value
If Criteria1 > 0 Then
DoCmd.Close acQuery, "FLTUsed4", acSaveNo
DoCmd.OpenForm "RefusalForm"
Else
DoCmd.Close acQuery, "FLTUsed4", acSaveNo
DoCmd.OpenQuery "LRQ3", acViewNormal
If LRQ3.CountofAuthorCalc2 > 0 Then
DoCmd.Close acQuery, "LRQ3", acSaveNo
DoCmd.OpenForm "RefusalForm2"
Else
DoCmd.Close acQuery, "LRQ3", acSaveNo
DoCmd.Close acForm, "PanelReservationForm", acSaveYes
DoCmd.OpenForm "ApprovalForm2"
End If
End If
End Sub