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

search function problem

P: 11
So I have a search form called ‘fdlgSearchPatient’
It is a search-as-you-type function. The function works fine so far.


Now I added EDIT and ADD NEW button but I don’t know how to link it.
I would like the FrmAuditTool to be pulled up when the user hit EDIT and frmNEW when the user hit ADD NEW button.

How do I make this work? The search as you type codes were simply copied from an online example.


The reason I have two forms is because ADD NEW would take the user to NEW FORM.. whereas EDIT will take the user to the saved record.


Please see the attached file for what I have created so far.
Thanks!
Attached Files
File Type: zip access SEARCH.zip (182.1 KB, 41 views)
Jan 5 '12 #1

✓ answered by Seth Schrock

Well, the database doesn't help much as most of the design feature have been disabled somehow. Anyway, for the Add New button, enter the following in the On Click event:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm "frmNEW"
  2. DoCmd.GoToRecord , , acNewRed
For the Edit button, I'm not sure what you have as the primary key for the records. I'm going to guess VisitID. If I'm correct, then you would add the following in the EDIT button's On Click event:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm "FrmAuditTool", , , "VisitID=" & VisitID
The part at the end of this code where is says
Expand|Select|Wrap|Line Numbers
  1. "VisitID=" & VisitID
works like this... The VisitID in the double quotes ("") is the name of the primary key field in the table supporting FrmAuditTool and the second VisitID (after the &) is the name of the control on fdlgSearchPatient that contains the Primary Key value. Keep in mind that I'm only guessing that the VisitID is the primary key field. If I'm wrong, then you will need to update that end code to make sure that it references the correct field or it won't work.

Share this Question
Share on Google+
3 Replies


Seth Schrock
Expert 2.5K+
P: 2,931
Well, the database doesn't help much as most of the design feature have been disabled somehow. Anyway, for the Add New button, enter the following in the On Click event:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm "frmNEW"
  2. DoCmd.GoToRecord , , acNewRed
For the Edit button, I'm not sure what you have as the primary key for the records. I'm going to guess VisitID. If I'm correct, then you would add the following in the EDIT button's On Click event:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm "FrmAuditTool", , , "VisitID=" & VisitID
The part at the end of this code where is says
Expand|Select|Wrap|Line Numbers
  1. "VisitID=" & VisitID
works like this... The VisitID in the double quotes ("") is the name of the primary key field in the table supporting FrmAuditTool and the second VisitID (after the &) is the name of the control on fdlgSearchPatient that contains the Primary Key value. Keep in mind that I'm only guessing that the VisitID is the primary key field. If I'm wrong, then you will need to update that end code to make sure that it references the correct field or it won't work.
Jan 6 '12 #2

P: 11
Thank you so much, Seth! :)
Jan 6 '12 #3

Seth Schrock
Expert 2.5K+
P: 2,931
Not a problem. Glad to help.
Jan 6 '12 #4

Post your reply

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