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

Autofill

P: 1
I am creating a form to enter patient information. Patient are identified by their medical record number. Patients can an will be return patients so there will be multiple records on patients. When I enter their medical record number, I would like other information such as name and address to autofill if they have been a patient before. How do I set this up?
Aug 11 '08 #1
Share this Question
Share on Google+
1 Reply


ADezii
Expert 5K+
P: 8,669
  1. Let's assume you have a Table named tblPatients with the following Fields:
    1. [RecordNumber]
    2. [FirstName]
    3. [LastName]
    4. [City]
    5. [State]
    6. [Zip]
  2. Let's also assume you have a Form with the following Fields (Text Boxes) :
    1. [txtRecordNumber]
    2. [txtFirstName]
    3. [txtLastName]
    4. [txtCity]
    5. [txtState]
    6. [txtZip]
  3. Place the following, or similar, code in the AfterUpdate() Event of txtRecordNumber:
    Expand|Select|Wrap|Line Numbers
    1. Private Sub txtRecordNumber_AfterUpdate()
    2. Dim txtRecID As TextBox
    3.  
    4. Set txtRecID = Me![txtRecordNumber]
    5.  
    6. If Not IsNull(txtRecID) And IsNumeric(txtRecID) Then        'legitimate value for Record Number?
    7.   'Is there a Patient with this Record Number?
    8.   If DCount("*", "tblPatients", "[RecordNumber] = " & txtRecID) <> 0 Then
    9.     Me![txtFirstName] = DLookup("[FirstName]", "tblPatients", "[RecordNumber] = " & txtRecID)
    10.     Me![txtLastName] = DLookup("[LastName]", "tblPatients", "[RecordNumber] = " & txtRecID)
    11.     Me![txtAddress] = DLookup("[Address]", "tblPatients", "[RecordNumber] = " & txtRecID)
    12.     Me![txtCity] = DLookup("[City]", "tblPatients", "[RecordNumber] = " & txtRecID)
    13.     Me![txtState] = DLookup("[State]", "tblPatients", "[RecordNumber] = " & txtRecID)
    14.     Me![txtZip] = DLookup("[Zip]", "tblPatients", "[RecordNumber] = " & txtRecID)
    15.   Else
    16.     MsgBox "No Patient exists with a Record Number of [" & txtRecID & "]"
    17.     'Should also clear Fields on any prior entries
    18.   End If
    19. Else
    20.   MsgBox "Invalid entry for Record Number"
    21. End If
    22. End Sub
  4. Let me know if you have any questions.
Aug 11 '08 #2

Post your reply

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