By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,940 Members | 614 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,940 IT Pros & Developers. It's quick & easy.

open a record,

P: 98
i have a form bound to a table, with a primary key(autonumber) "recordno"
on this form, i have a dlookup that looks up a specific "recordno".

how can i get this form to open up the record corresponding to the value that the dlookup outputs.
Dec 23 '08 #1
Share this Question
Share on Google+
1 Reply


puppydogbuddy
Expert 100+
P: 1,923
in the code below txtrecordno represents the textbox on the form that you are using for the recordno you want to display via the DLookup, although your use of the DLookup to determine what record you want to display does not make sense to me. Replace any illustrative names I used for the objects in your application with their actual names.

Expand|Select|Wrap|Line Numbers
  1. Private Sub txtrecordno_AfterUpdate()
  2. If DCount("[recordno]", "YourTable", "[recordno] = " & Me.txtrecordno) > 0 Then
  3.         DoCmd.OpenForm Me, , , "[recordno] = " & Me.txtrecordno
  4. Else
  5.         MsgBox "The recordno you entered does not exist."
  6.         Me.txtrecordno.SetFocus
  7. End If
  8. End Sub
  9.  
Dec 23 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.