Auto fill text boxes using SELECT query (1 Viewer)

lumiere

New member
Local time
Yesterday, 23:02
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

  • Test 25.09.accdb
    768 KB · Views: 193

Ranman256

Well-known member
Local time
Today, 02:02
Joined
Apr 9, 2015
Messages
4,339
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
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 14:02
Joined
May 7, 2009
Messages
19,228
here test this.
 

Attachments

  • Test 25.09.zip
    65 KB · Views: 199

lumiere

New member
Local time
Yesterday, 23:02
Joined
Nov 10, 2019
Messages
29
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

Top Bottom