Hi

I have (am) taught myself VBA for MS Access but not real well and do not have a programming background. I hope you may be able to help...

first question... I have the following code:

Dim db As Database
Dim qrystrBookingStatus
Dim rstBookingStatus As Recordset
Dim varStatusItemStatus As String

Set db = CurrentDb

'MsgBox "varCurrentStatusField - " & varCurrentStatusField

' Check the current booking status value - true or false
qrystrBookingStatus = "select KitSent from tblBookingInfo" & _
" where BookingId = " & Chr(34) & Me.BookingId & Chr(34) & ";"
Set rstBookingStatus = db.OpenRecordset(qrystrBookingStatus, dbOpenDynaset)
varStatusItemStatus = rstBookingStatus!KitSent
rstBookingStatus.Close


----

you will notice the hardcoded field "KitSent" in the select statement.

I would like to make this code a subroutine that I can call and pass the field as a variable such as:

Dim db As Database
Dim qrystrBookingStatus
Dim rstBookingStatus As Recordset
Dim varStatusItemStatus As String
Dim fieldvariable as string

Set db = CurrentDb

'MsgBox "varCurrentStatusField - " & varCurrentStatusField

' Check the current booking status value - true or false
qrystrBookingStatus = "select " & fieldvariable & " from tblBookingInfo" & _
" where BookingId = " & Chr(34) & Me.BookingId & Chr(34) & ";"
Set rstBookingStatus = db.OpenRecordset(qrystrBookingStatus, dbOpenDynaset)
varStatusItemStatus = rstBookingStatus!fieldvariable
rstBookingStatus.Close

---

but then when I try and asign the retrieved value from the query (i.e. varStatusItemStatus = rstBookingStatus!fieldvariable) VBA does not use the value of the variable fieldvariable but takes it literally!

How do I do this?

Many thanks in advance.

MG