I want to run queries in VBA. The queries are used for calculations, but I can't find the right command to run a query. The queries are in the DB. Or do I have to type the queries in the code?
Can ne1 help plz?
Can ne1 help plz?
With DoCmd
.SetWarnings False
.OpenQuery <queryname>
.SetWarnings True
End With
Public Sub Planning()
DoCmd.SetWarnings False
If cmbResProgID = 2 Or 3 Then
Dim QryMore6 As QueryDef
QryMore6 = DoCmd.OpenQuery(qryCodeSwim9AML) + DoCmd.OpenQuery(qryCodeSwim9AMT)
If QryMore6 > 6 Then
QueryEMore6 'Private sub with calculations'
Else
QueryELess6 'Private sub with calculations'
End If
Else
End If
DoCmd.SetWarnings True
End Sub
Dim qryCodeSwim9AML, qryCodeSwim9AMT
If programBlocal + ProgramBtourist > 6 then 'there shouldnt be more then 6
people for program A'
CheckProgramAMore6 'Program A can only have 6 or less reservations'
else
CheckProgramALess6 'Program A can have 0 - 18 reservations'
end if
Private Sub CheckProgramAMore6()
If programAlocal + ProgramATourist > 6 then 'theres an arror,
this is not possible'
MsgBox "This reservation is not possible. There are x program A en x program b.
Please try another time / date"
else 'reservation is verified'
docmd.save
end if
end sub
Private Sub CheckProgramALess6()
If programAlocal + ProgramATourist > 18 then 'theres an arror,
the maximum is 18'
MsgBox "This reservation is not possible. There are x program A en x program b.
Please try another time / date"
else 'reservation is verified'
docmd.save
end if
end sub