strSql errors

Whilst my code is working OK.

It currently updates the [Location] based on the [DepartmentBookingOut] field.

In the PoolBookings form, the user selects the [DepartmentBookingOut] from a List Box. Almost all departments should be in the box, however in case they aren't, I added another field in the PoolBookings table called [DepartmentBookingOutNotInList].

The way the code is set up at the moment, will work perfectly as long as the user selects the correct [DepartmentBookingOut].

I wanted to use an IF statement within an IF statement. I don't know whether this is possible.

I want the IF statement to look at whether the [DeparmentBookingOut] is null, so I'm guessing it would look like this...

Code:
Dim db As DAO.Database

If [DepartmentBookingOut] Is Null Then

Me.Location = Me.DepartmentBookingOutNotInList

Else

Me.Location = Me.DepartmentBookingOut

End If

When I run this I get an Object Required message.
 
change it to:

If Len([DepartmentBookingOut] & "") = 0 Then
...
...

Or

IF [DepartmentBookingOut].ListIndex < 0 Then
...
...
 
@kevnaff,

Do you have Option Explicit declared at the top of every code module (above or below Option Compare Database)?

If not, add it to every module, and Debug menu -> Compile

It will highlight any undeclared variable errors in your code (one by one, you have to fix, repeat until there are no more errors.)

In the code above Message, Title and Response are undeclared
 
I have created a query called QueryPoolBookings with PoolBookings and ImportEquipment tables, and included all fields from PoolBookings and just the Location field from ImportEquipment. I have changed the form's record source to QueryPoolBookings.
Unless you have used an OUTER JOIN you will only ever show records where the CodeNo/[Code No] appears in both tables.

You will never see any records in your form where the CodeNo is in PoolBookings but not in ImportEquipment.
 

Users who are viewing this thread

Back
Top Bottom