combining fields

F

fiona.innes

Hi

I have a table called tblDetails and in this table there are 2 field
called strGateID (autonumber) and srtPN which is a default value of
PN. I have combined two field in a query called qrySearch and the new
field is called srtSearchNo.
On my main page frmMain I have a listbox (lstSearch) this displays all
the data in the tblDetails via the qrySearch. When I double click on a
record in the list box I wish it to display all the relevant date on a
new form called frmResults.

Private Sub ShowRecord_Click()

'Find a selected record, then close the search dialog box

DoCmd.OpenForm "frmResults1", , , _

"[qrySearch.strSearchNo]=" & "'" & Me.lstSearch.Column(2) & "'"

'Close the dialog box

DoCmd.Close acForm, "frmMain"

End Sub

only problem is when I run the search it comes up with an error saying

Run-Time errror '3126'
Invalid bracketing of name '[qrySearch.srtSearchNo]


does anyone know how to resolve this?

Thank

Fiona
 
M

Marshall Barton

I have a table called tblDetails and in this table there are 2 field
called strGateID (autonumber) and srtPN which is a default value of
PN. I have combined two field in a query called qrySearch and the new
field is called srtSearchNo.
On my main page frmMain I have a listbox (lstSearch) this displays all
the data in the tblDetails via the qrySearch. When I double click on a
record in the list box I wish it to display all the relevant date on a
new form called frmResults.

Private Sub ShowRecord_Click()

'Find a selected record, then close the search dialog box

DoCmd.OpenForm "frmResults1", , , _

"[qrySearch.strSearchNo]=" & "'" & Me.lstSearch.Column(2) & "'"

'Close the dialog box

DoCmd.Close acForm, "frmMain"

End Sub

only problem is when I run the search it comes up with an error saying

Run-Time errror '3126'
Invalid bracketing of name '[qrySearch.srtSearchNo]


There is no need for brackets in that condition. If you
needed them, they would have to be around each individual
name (e.g. [qrySearch].[strSearchNo]


You probably do not need the table/query name either.
Assuming strSearchNo is a Text field, try using just:

DoCmd.OpenForm "frmResults1", , , _
"strSearchNo='" & Me.lstSearch.Column(2) & "'"
 

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

Similar Threads

combining field 4
Refreshing list boxes 3
refreshing a list box 1
Searching for records 1
Help with vba 2
Control Source problem? 3
Combo box on report 6
can't save record error 1

Top