Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Command Buttons Opening Forms from a Form

Status
Not open for further replies.

MontgomeryPete

Instructor
Apr 3, 2004
57
US
When a continuous form is opened, the user is requested to enter the relevant date (OnLoad). This form will be open consistently throughout the day. Therefore, the form must be refreshed and there are two forms that the user may wish to reference from a value on the current record.

The problem is that the user is getting the prompt "Enter the Date" on requery or use of the other commmand buttons. I have tried calling the function On Open and On Activate with the same results.

The code is shown below. I would be grateful for any help. Thanks in advance.

...Requery button
Private Sub cmdRequeryDispatchLog_Click()
On Error GoTo Err_cmdRequeryDispatchLog_Click

Dim stDocName As String

stDocName = "qryDispatch"
DoCmd.OpenQuery stDocName, acNormal, acEdit

Exit_cmdRequeryDispatchLog_Click:
Exit Sub

Err_cmdRequeryDispatchLog_Click:
MsgBox Err.Description
Resume Exit_cmdRequeryDispatchLog_Click

...Vehicle Assignment button

Private Sub cmdAssignment_Click()
On Error GoTo Err_cmdAssignment_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmAssignments"

stLinkCriteria = "[VehicleNo]=" & Me![VehicleNumber]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdAssignment_Click:
Exit Sub

Err_cmdAssignment_Click:
MsgBox Err.Description
Resume Exit_cmdAssignment_Click

End Sub

...Driver Status button
Private Sub cmdStatus_Click()
On Error GoTo Err_cmdStatus_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmDriversStatus"

stLinkCriteria = "[VehicleNo]=" & Me![VehicleNumber]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdStatus_Click:
Exit Sub

Err_cmdStatus_Click:
MsgBox Err.Description
Resume Exit_cmdStatus_Click

End Sub


 
I am not exactly clear on what you are doing. Is it possible to store the date in a global variable and only ask for a date if the global variable is not correct?
 
Thanks Remou, the global variable did the trick. I appreciate the prompt response.
Pete

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top