Where In Wrong Place

D

DS

I have a Form that I'm opening from another Form...Its suppose to open a
New Record which it does if the SalesID is Null. The SalesID is in a
listbox column 3...this works fine, what doesn't work is that whenever I
want to go to a record that I choose on the first form, it doesn't go
there, it goes to the first record in the set. Heres my code, did I do
something wrong?

Private Sub TableNum_Click()
If IsNull(Me.TableNum.Column(2)) Then
DoCmd.OpenForm "Sales", acNormal, "", "", , acNormal
DoCmd.GoToRecord acForm, "Sales", acNewRec
Forms!Sales!Server = Forms!Tables!Text16
Forms!Sales!GetTableNum = Forms!Tables!TableNum
DoCmd.Close acForm, "Tables"
DoCmd.OpenForm "Menus", acNormal, "", "", , acNormal
Else
DoCmd.OpenForm "Sales", acNormal, "",
Forms!Tables!TableNum.Column(2), acFormEdit
End If
End Sub

Its the last line before the end if

Thanks for any help or suggestions
DS
 
N

Nikos Yannacopoulos

DS,

Try this line instead:

DoCmd.OpenForm "Sales", , , "FieldX =" _
& Forms!Tables!TableNum.Column(2)

if FieldX is numeric, or

DoCmd.OpenForm "Sales", , , "FieldX ='" _
& Forms!Tables!TableNum.Column(2) & "'"

if FieldX is text, where FieldX is the name of the table field to which
the target control is bound.

HTH,
Nikos
 
D

DS

Nikos said:
DS,

Try this line instead:

DoCmd.OpenForm "Sales", , , "FieldX =" _
& Forms!Tables!TableNum.Column(2)

if FieldX is numeric, or

DoCmd.OpenForm "Sales", , , "FieldX ='" _
& Forms!Tables!TableNum.Column(2) & "'"

if FieldX is text, where FieldX is the name of the table field to which
the target control is bound.

HTH,
Nikos
That worked!!! Thank You ver much!!!
DS
 

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


Top