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

Search as you type question

P: 11
I have a search form which has the SEARCH AS YOU TYPE function.

Now when I double clicked on to the searched item, it will show me the main form with all the information that has been saved including the subform but it does not take me directly to the specific record in the subform.

For instance, In my main form, I have an option to choose A.M., LUNCH or P.M.

Accordingly, whichever one I click, it will be visible as a subform. For example, if I click A.M., the A.M. SUBFORM will be visible. If I click LUNCH, the LUNCH SUBFORM will be visible and the rest hidden.

How do I link subform to the search form so that if I click on to MR.A’s form for LUNCH time only, it will open up the main form with LUNCH subform.

Sorry, I know this is confusing. I hope someone understands me!
Jan 5 '12 #1
Share this Question
Share on Google+
12 Replies

Expert Mod 10K+
P: 12,366
In your code where you open the form, use the WHERE parameter to filter for the record you want.
Jan 5 '12 #2

P: 11
Sorry Rabbit.
I did not quite understand.
I do have vb codes for setfilter.

Did you mean I add another line to it to state which record?
Jan 5 '12 #3

Expert Mod 10K+
P: 12,366
Not another line. I assume you're using a DoCmd.OpenForm to open the form. That method has an argument that you can use to specify a where clause so you can open it to that record.
Jan 5 '12 #4

P: 11
I still did not really get what you are trying to say. I have attached a copy of my work here. I hope you can help me out.

Basically, when I click on to EDIT a record , the subform does not match what I am looking for.
I am using a DoCmd.OpenForm

Thanks Rabbit!
Attached Files
File Type: zip access (227.9 KB, 128 views)
Jan 6 '12 #5

Expert Mod 10K+
P: 12,366
Can you post the code instead?
Jan 6 '12 #6

P: 11
this is what I have for EDIT command
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command0_Click()
  4.     DoCmd.OpenForm "frmAuditTool", , , "StudyID=" & StudyID
  8. End Sub
Jan 6 '12 #7

P: 11
I am not sure if you would like to see this too,,
Expand|Select|Wrap|Line Numbers
  1. Private Function SelectPatient(ByVal lngStudyID As String)
  3.     DoCmd.OpenForm "FrmAuditTool", , , "StudyID = " & Me.txtMetricsID
  4.     DoCmd.Close acForm, "fdlgSearchPatient"
  6. End Function
  11. Private Sub Form_Open(Cancel As Integer)
  12. ' Make sure filter/order is off, so that it will open faster
  13. #If Not CC_Debug Then
  14. On Error GoTo ErrProc
  15. #End If
  17.     ClearFilter
  19. ExitProc:
  20.     Exit Sub
  21. ErrProc:
  22.     Err.Msg Err, Err.Description, Err.Source
  23.     Resume ExitProc
  24. End Sub
Jan 6 '12 #8

Expert Mod 10K+
P: 12,366
I think I see now. I missed the subform part. You can pass which one you chose in the OpenArgs parameter and then use that to make the correct subform visible using the OnLoad event of the form.
Jan 6 '12 #9

P: 11

Thank you again Rabbit

this is what I added to my existing code
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command0_Click()
  3.     DoCmd.OpenForm "frmAuditTool", , , "StudyID=" & StudyID, OpenArgs:="Parameter (s)"
  5. End Sub
I have never used OpenArgs. Could you please help.
You mean in OnLoad, I use code like:
Expand|Select|Wrap|Line Numbers
  1. Me.CopyFrmAuditTool.visible = true
and thats it? Do I have to add anything to it?
Jan 6 '12 #10

Expert Mod 10K+
P: 12,366
Well, I thought you wanted to make a certain subform visible depending on whether they clicked on am, lunch, or pm? That's what should be passed in OpenArgs. Then in the OnLoad, you can check what the OpenArgs is and make the correct subform visible.
Jan 6 '12 #11

P: 11
what should I put under parameter?

"A.M. or LUNCH or P.M." ?
Jan 6 '12 #12

P: 11
OK.. let me try again
Jan 6 '12 #13

Post your reply

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