Hi,
I have a command button that uses DoCmd.OpenForm to find a specifc related record for the form it is opening and then closes the old form. The problem is that when there is not related record, it either opens completely blank or wants to create a new record. I would like to add an If clause (or something) that says if there is no match then goto the first record of the NEW form (or table on which the new form is based). I know this is probably pretty simple, but it seems like someone out there might be able to help me quicker and better than I could help myself.
Here's what I have right now. Thanks in advance. Dan.
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmPurchasing"
stLinkCriteria = "[JobNo]=" & Me![txtJobNo]
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, "frmJobs", acSaveNo
I have a command button that uses DoCmd.OpenForm to find a specifc related record for the form it is opening and then closes the old form. The problem is that when there is not related record, it either opens completely blank or wants to create a new record. I would like to add an If clause (or something) that says if there is no match then goto the first record of the NEW form (or table on which the new form is based). I know this is probably pretty simple, but it seems like someone out there might be able to help me quicker and better than I could help myself.
Here's what I have right now. Thanks in advance. Dan.
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmPurchasing"
stLinkCriteria = "[JobNo]=" & Me![txtJobNo]
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, "frmJobs", acSaveNo