How to check for exisiting records

T

Tony Williams

I have a a table called tblindividual which holds data on individuals. The
table includes two fields txtfirstname and txtsurname. I have a form called
frmregistration. What I want to do is when the user has input the surname I
want to check if there is a record where the combination of [txtfirstname]
+[txtsurname] already exists and if it does open a form that lists all the
records where that combination exists and then be able to select a
particular record to view their data in another copy of frmregistration.
I assume I'm going to have to use VBA code to do this, I'm very rusty in
that. Can this be done?
Thanks
Tony
 
O

OldPro

I have a a table called tblindividual which holds data on individuals. The
table includes two fields txtfirstname and txtsurname. I have a form called
frmregistration. What I want to do is when the user has input the surname I
want to check if there is a record where the combination of [txtfirstname]
+[txtsurname] already exists and if it does open a form that lists all the
records where that combination exists and then be able to select a
particular record to view their data in another copy of frmregistration.
I assume I'm going to have to use VBA code to do this, I'm very rusty in
that. Can this be done?
Thanks
Tony

Yes, this can be done. A SQL SELECT statement can be used to retrieve
the records in question. It can populate a listbox on the same form,
or a new form. Selecting an item in the listbox could cause another
form to be opened, which would display the item in greater detail.
Start by putting a listbox on your form, and figuring out what SQL
statement to put in the .Rowsource property, to populate it with the
records that you want. You will probably need some dummy records,
i.e. "John Smith" to test it.
 
T

Tony Williams

Thanks for that but how do I get to check if what the user has entered
already exists? Have I missed something?
Thanks
Tony
OldPro said:
I have a a table called tblindividual which holds data on individuals.
The
table includes two fields txtfirstname and txtsurname. I have a form
called
frmregistration. What I want to do is when the user has input the surname
I
want to check if there is a record where the combination of
[txtfirstname]
+[txtsurname] already exists and if it does open a form that lists all
the
records where that combination exists and then be able to select a
particular record to view their data in another copy of frmregistration.
I assume I'm going to have to use VBA code to do this, I'm very rusty in
that. Can this be done?
Thanks
Tony

Yes, this can be done. A SQL SELECT statement can be used to retrieve
the records in question. It can populate a listbox on the same form,
or a new form. Selecting an item in the listbox could cause another
form to be opened, which would display the item in greater detail.
Start by putting a listbox on your form, and figuring out what SQL
statement to put in the .Rowsource property, to populate it with the
records that you want. You will probably need some dummy records,
i.e. "John Smith" to test it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top