Data Lookup But Not From A Combo???

  • Thread starter Thread starter perimom
  • Start date Start date
P

perimom

Guest
I have two forms. Main one is medical records, with button History on it. You click it, and the History form appears. Now, here's my question: how can I make it, so that every time you click a History button, a History form pulls out data(from a query...or not?) for that very person, who's medical record I was just displaying? My history form contains: date field; and history entry field(text). It DOES NOT CONTAIN name of a person - I would like for the form to automatically pull it from the main form and display a different name each time, based on which name I am displaying NOW in the main form. One person can have many history entries, so I keyed them for the query. I can email my db, if its not clear enough. THANK YOU!!!! I've been searching to solve this for so long!
A few notes, just to save you time:
--- second form is not a subform;
--- even know it is a data lookup, I don't need a combo box - just person's name and linked to it records(or empty field, if it hasn't been populated yet...zero length allowed, if the disease was without complications)
Thank you in advance!!!!!!
 
If I understand you right, you should have two separate tables attached to two separate forms, with a relationship setup connecting the Patient table to the History table through a unique ID field instead of the patients name (to eliminate getting patient names mixxed up).
When you click on the "History" command button on the Main form after a Patient is loaded the code to load the History form and select the correct data should look like the following:
Code:
    Dim strWhere As String
    strWhere = "[ID]=" & Me![ID]
    DoCmd.OpenForm "frmHistory", , , strWhere

This will load all history records relating to the Patent that is selected on the main form.

If this isn't clear, go ahead and email it to me and I'll give it a gander.
 
Last edited:
Thank you, I have tried it. I have wrote this code into OnOpen property of the History form. Should I have put it elswhere? It returns me a msg "Access cant find macro DoCmd". Do I have to create a macro now?
Thanks!
 
Last edited:
A. dont use a macro

B. insert into the code under the command button on your Main form that you click on to open the History form. Should read like so:
Code:
Private Sub cmdOpenHistory_Click()
    Dim strWhere As String
    strWhere = "[ID]=" & Me![ID]
    DoCmd.OpenForm "frmHistory", , , strWhere
End Sub
 

Users who are viewing this thread

Back
Top Bottom