Auto fill text boxes using SELECT query

lumiere

New member
Local time
Yesterday, 16:30
Joined
Nov 10, 2019
Messages
29
I am sharing the database as .rar file.

'tblCust' contains information about the customers - Name, Age, Address, Contact, Date of entry and serial number. 'frmCust' is used by user to add information to 'tblCust'. 'frmSearch' contains two text-boxes which are to be filled with date of entry and serial number by the user. A button is given to run a query ('qrySearch') which takes in inputs fron both of the above boxes, and generates all the records of that individual customer. There will be only one customer with a serial number on a given date, so the result of 'qrySearch' will always have one record.

All I want is the text-boxes to be filled, i.e. to show the records of name, age, address and contact once the records match according to date and serial.

I have tried to set the record source of the form to 'qrySearch' and control sources of the text-boxes to their respective controls, but it is not working.

I am really new at this and perhaps making some really trivial mistake, please help me through this. Any help would be greatly appreciated.
 

Attachments

make a form that shows all data from a table. (usu a continuous form)
then put the 2 text boxes in the form header.
when user fills in the search boxes, user clicks SEARCH btn, that filters the data using the code ( CLICK event)

Code:
sub btnSearch_click()
dim sWhere as string

sWhere = "1=1"
if not IsNull(txtBox1) then sWhere = sWhere & " and [field1]='" & me.txtBox1 & "'"
if not IsNull(txtBox2) then sWhere = sWhere & " and [field2]='" & me.txtBox2 & "'"


if sWhere = "1=1" then
   me.filterOn = false
else
   me.filter = sWhere
   me.filterOn = true
endif
 
here test this.
 

Attachments

make a form that shows all data from a table. (usu a continuous form)
then put the 2 text boxes in the form header.
when user fills in the search boxes, user clicks SEARCH btn, that filters the data using the code ( CLICK event)

Code:
sub btnSearch_click()
dim sWhere as string

sWhere = "1=1"
if not IsNull(txtBox1) then sWhere = sWhere & " and [field1]='" & me.txtBox1 & "'"
if not IsNull(txtBox2) then sWhere = sWhere & " and [field2]='" & me.txtBox2 & "'"


if sWhere = "1=1" then
   me.filterOn = false
else
   me.filter = sWhere
   me.filterOn = true
endif
Thanks I'll test this out
 

Users who are viewing this thread

Back
Top Bottom