I am trying to open a form based on 2 different criteria.
I have a form [frmJobs] with a button to open [frmNewPO]. This form is an intermediate between jobs and actual purchase orders, so taht 1 job can have multiple Purchase Orders. This form will list all PO for that particular job. This form has a JobNumber field (bound to JobNumber), a list box taht shows all the po's for that job.
I would like this [frmNewPO] form to act in 2 different cases. First has described above, and second I would like this form to be used outside of jobs, so the user can create Purchase Orders for 'Stock'.
If the form is opened from the Jobs form, it is linked to the proper Job Number. If the form is opened on it's own then it has to goto 'Stock'. This is were i have trouble making this happened.
This is the code that opens the form form the jobs form:
This is the code i have so far on the open event of the frmNewPO:
after the else statment, should say 'goto record Stock', but i don't know how to acheive this.
Can someone shed some light on this matter?
Thanks,
Sylvain
I have a form [frmJobs] with a button to open [frmNewPO]. This form is an intermediate between jobs and actual purchase orders, so taht 1 job can have multiple Purchase Orders. This form will list all PO for that particular job. This form has a JobNumber field (bound to JobNumber), a list box taht shows all the po's for that job.
I would like this [frmNewPO] form to act in 2 different cases. First has described above, and second I would like this form to be used outside of jobs, so the user can create Purchase Orders for 'Stock'.
If the form is opened from the Jobs form, it is linked to the proper Job Number. If the form is opened on it's own then it has to goto 'Stock'. This is were i have trouble making this happened.
This is the code that opens the form form the jobs form:
Code:
Private Sub cmdPO_Click()
On Error GoTo Err_cmdPO_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmNewPO"
stLinkCriteria = "[JobNumber]=" & "'" & Me![JobNumber] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord , , acNewRec
Exit_cmdPO_Click:
Exit Sub
Err_cmdPO_Click:
MsgBox Err.Description
Resume Exit_cmdPO_Click
End Sub
This is the code i have so far on the open event of the frmNewPO:
Code:
Private Sub Form_Open(Cancel As Integer)
If IsFormOpen("frmJobs") Then
Me.[txtJobNumber].DefaultValue = "[Forms]![frmJobs]![JobNumber]"
MsgBox "jobs opened" 'debug
Else
MsgBox "jobs not opened" 'debug
Me.[txtJobNumber].DefaultValue = "stock"
' Me.Filter("jobnumber") = "Stock"
End If
End Sub
after the else statment, should say 'goto record Stock', but i don't know how to acheive this.
Can someone shed some light on this matter?
Thanks,
Sylvain