populate unbound textboxes

Qamar

Registered User.
Local time
Today, 12:28
Joined
Jun 28, 2004
Messages
42
I have a small database with three tables as follows:

tblPerson
PersonID
LastName
FirstName

tblOffence
OffenceID
Offence

tblPersonsOffences
PersonsOffencesID
PersonID
Offence
DateofOffence
ReportedBy
Remarks

Now in the form frmPersonsOffences, I have created two unbound textboxes, so that when I type the PersonID, the name and surname will be displayed to better identify the person. What is the best way to put the name and surname in these two textboxes? I was thinking to create an SQL statement such as "SELECT tblPerson.LastName FROM tblPerson WHERE tblPerson.PersonID = [Forms]![frmPersonsOffences]![txtPersonID] but I am not sure where I should put this code.

Thanks in advance for your help.
 
Create a Combo Box on the form that uses the ID Field and also the First Name and Last Name then hide the 2 columns by changing the properties and column width to 0 (zero) for the first name and last name then you can add a simple After Update Event so when you select the ID it will add the first name to the text box and the Last Name to the other text box.

The code would be something like this

me.TextBoxFirstName=me.cboID.Column(1)
me.TextBoxLastName=me.cboID.Column(2)
 
I would appear that you are now attempting to populate the records in the "tblPersonsOffences" table. If this is the case, rather than have to type the record id for the person (which is hard to remember) why not display a list of the available persons in either a combo box bound to the "PersonID" field where you can display the name but have the RecordID value stored in the field. Then you can just have your other fields bound to the remaining fields in the "tblPersonsOffences" table.
 
thank you very much both for your replies, it is making more sense now.
 

Users who are viewing this thread

Back
Top Bottom