Double click listbox to fill the another form

G

Guest

Hi,
I have a form that search CustomerID and list it on the listbox. Then I can
double click the selected ID and it will open the 2nd form and automatically
fill the 2nd form with the data of particular CustomerID.

I can search it, double click the list box and open the 2nd form but..
the data do not fill up automatically at the 2nd form unless if the I have
opened the 2nd form from the beginning, it will fill it up successfully.

Did I miss something? Teach me please.
 
G

Guest

To open other form with double click the list box:
Private Sub lstResults_DblClick(Cancel As Integer)
On Error GoTo Err_btnSelect_Click

If Not IsNull(Me![lstResults].Column(0)) Then
DoCmd.OpenForm "Customers_Information2", , , "[Customers.CustomerID]='"
& Me.lstResults.Column(0) & "'"
End If
Exit Sub

Err_btnSelect_Click:
MsgBox Err.Number
Exit Sub
End Sub
 
D

Douglas J. Steele

Try changing "Customers.CustomerID]=" to simply "[CustomerID]="

Is CustomerID a text field? If not, remove the single quotes.

Does Me.lstResults.Column(0) return what you think it does? Try putting a
MsgBox in there to double check.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


yanz said:
To open other form with double click the list box:
Private Sub lstResults_DblClick(Cancel As Integer)
On Error GoTo Err_btnSelect_Click

If Not IsNull(Me![lstResults].Column(0)) Then
DoCmd.OpenForm "Customers_Information2", , , "[Customers.CustomerID]='"
& Me.lstResults.Column(0) & "'"
End If
Exit Sub

Err_btnSelect_Click:
MsgBox Err.Number
Exit Sub
End Sub

Douglas J. Steele said:
What's the code you're using?
 
G

Guest

Try changing "Customers.CustomerID]=" to simply "[CustomerID]="
Is CustomerID a text field? If not, remove the single quotes.

I tried to change it to CustomerID but it still like that..other form still
got blank.
Does Me.lstResults.Column(0) return what you think it does? Try putting a
MsgBox in there to double check.

Yeah, it return all the data I want but can you help me where to put MsgBox
for double check. Im a newbie so maybe you can show me step by step..
 
D

Douglas J. Steele

Private Sub lstResults_DblClick(Cancel As Integer)
On Error GoTo Err_btnSelect_Click

If Not IsNull(Me![lstResults].Column(0)) Then
MsgBox Me.lstResults.Column(0)
DoCmd.OpenForm "Customers_Information2", , ,_
"[Customers.CustomerID]='" & Me.lstResults.Column(0) & "'"
End If

Exit Sub

Err_btnSelect_Click:
MsgBox Err.Number
Exit Sub
End Sub


--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


yanz said:
Try changing "Customers.CustomerID]=" to simply "[CustomerID]="
Is CustomerID a text field? If not, remove the single quotes.

I tried to change it to CustomerID but it still like that..other form
still
got blank.
Does Me.lstResults.Column(0) return what you think it does? Try putting a
MsgBox in there to double check.

Yeah, it return all the data I want but can you help me where to put
MsgBox
for double check. Im a newbie so maybe you can show me step by step..
 

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

Double Listbox 2
ListBox focus 4
Fill A Listbox In A Continuous Form 8
setfocus to 1st tab after requery on 2nd tab 2
Access Click in Table to Open Form 0
Access Cannot select items in listbox 1
listbox question 2
Listbox Double Vision 6

Top