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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open a Form to a specific record on another form

Status
Not open for further replies.

stru

Programmer
Mar 23, 2002
10
US
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
 
You must check for null before you close the first form.

This code works for me. I hope it helps.

If IsNull(Forms![YOURFORM]![YOURCONTROL]) Then
MsgBox "YOUR MESSAGE"
 
Thaat worked. Thanks for the help MooseMan.

Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top