very very basic syntax problem

antonyx

Arsenal Supporter
Local time
Today, 14:37
Joined
Jan 7, 2005
Messages
556
hi.. dont have much time.. haven't touched access for months..

trying to use a link criteria with a number datatype.. the form opens but the chosen record doesnt display..

here is a text datatype version that works..

Code:
Private Sub quicksearch3_DblClick(Cancel As Integer)
Dim stLinkCriteria As String
stLinkCriteria = "[JobRef]=" & "'" & Me![quicksearch3].Column(0) & "'"
DoCmd.OpenForm "3bookings", , , stLinkCriteria
End Sub

tried tweaking it to allow a number datatype to be used.. like i said.. isnt working.

Code:
Private Sub quicksearch4_DblClick(Cancel As Integer)
Dim stLinkCriteria As String
stLinkCriteria = "[bookingid] = " & Me![quicksearch4].Column(0) & ""
DoCmd.OpenForm "2bookings", , , stLinkCriteria
End Sub
 
no that is still opening the form with blank fields..
 
is the booking ID an actual #?
and is it the control source of the combo box?
 
ok.. the listbox is populated from a query..
6 fields...

the primary key is called id and is the first field..

the column widths are as follows..

0cm;2cm;2cm;2cm;2cm;2cm (so the id doesnt display but is still there)

i have set the bound column of the listbox as 1

the listbox code is here..
Code:
Private Sub lst0bookings_DblClick(Cancel As Integer)
Dim stLinkCriteria As Integer
[b]stLinkCriteria = "[id] = " & Me![lst0bookings].Column(0)[/b]
DoCmd.OpenForm "0bookings", , , stLinkCriteria
End Sub

gettin error 13.. type mismatch on above bold line..
 
i have set the bound column of the listbox as 1
Then how come u have booking ID set to column (0)???

Just change it to
Code:
Me.[lst0bookings]
i dont think u need the column# if you have it bound!
 
ok.. using this it opens the new form.. but it only opens it at the first record.. not the chosen one..

Code:
Private Sub lst0bookings_DblClick(Cancel As Integer)
Dim stLinkCriteria As Integer
stLinkCriteria = Me.[lst0bookings]
DoCmd.OpenForm "0bookings", , , stLinkCriteria
End Sub

this happens when i set the bound column to 1 and 0...

do i need to add some on open event to the new form.. i didnt think i needed to..
 
Code:
stLinkCriteria = "[id] = " & Me![lst0bookings]
oops i meant this!
 
now im gettin type mismatch with the bound as 1 and 0 again.. using this..

Code:
Option Compare Database

Private Sub lst0bookings_DblClick(Cancel As Integer)
Dim stLinkCriteria As Integer
stLinkCriteria = "[id] = " & Me![lst0bookings]
DoCmd.OpenForm "0bookings", , , stLinkCriteria
End Sub

does it have anything to do with.. as integer or cancel as integer
 
yeah, i removed.. as integer.. and it worked.. thank you sir..
 
Ah yes, i didnt even see that part! sorry.

glad you got it figured out
 

Users who are viewing this thread

Back
Top Bottom