simple search sql

penfold1992

Registered User.
Local time
Today, 14:47
Joined
Nov 22, 2012
Messages
169
I have combo box that searches records.

When that record gets picked, I want to fill in some other boxes corresponding to the record... I have a method to get the data but I want to know if there is an easier way.

in the afterupdate field:

Code:
Dim dbs As DAO.Database
Dim rstReq As DAO.Recordset
Dim strSQL As String
Dim str As String
 
strSQL = "SELECT * FROM [tbl] WHERE [tbl].[Model]=" & Me.searchcmb
Set rstReq = dbs.OpenRecordset(strSQL)
 
 
If Not IsNull(rstReq![Date received]) Then
    Date1 = rstReq![Date received]
    strDateRec = Date1
Else
    strDateRec = ""
End If

im sure there is a better way than this?
 
that would put all the info into the combo box.

instead, the info i want to display is from a large table with sections getting populated based on the value from the combo box.
I still want to display each value seperately in its own box, as i said, the above method works however its reasonably clunky and heavy in my opinion. I was wondering if there was an easier method to achieve the same result.
 
Did you read the information in the Link provided?
 
yes but that would involve loading a combo box which I dont want to do. regardless of if you can see it or not, the amount of information the combo box will hold will be enourmous.
 
Does this work for you?

Code:
Dim rstReq As Recordset
Dim strDateRec As String
 
Set rstReq = currentdb.OpenRecordset("SELECT * FROM [tbl] WHERE [tbl].[Model]=" & Me.searchcmb)
 
 strDateRec = nz(rstReq![Date received], "")

This should accomplish the exact same thing with less coding
 

Users who are viewing this thread

Back
Top Bottom