gchichester
New member
- Local time
- Today, 15:23
- Joined
- Nov 13, 2008
- Messages
- 8
I can't figure out why I keep getting a "type mismatch" error when this SQL statement runs from my form.
I have this same statement as a query and it runs correctly.
Data type for the "UsedBookingNumbers" fields are Text.
Users may not have a booking number at the time of entry so they add a " - " to the field for aesthetics purposes, it's using in a Email subject line.
I'm using a table to store and then lookup numbers to prevent the duplicating of booking numbers.
Because there can be a lot of " - " and I'm checking for used numbers at data entry, the user gets my message that the number has been used.
So I'm trying to delete only records with a " - ". before the user enters another record.
I've tried using the Report Close and Lost Focus Event to run the DoCmd.RunQSL but both get the same error.
SQL Code used:
Sql_ClearNoBookingNumber = "Delete tblUsedBookingNumbers.UsedBookingNumbers FROM tblUsedBookingNumbers
WHERE (((tblUsedBookingNumbers.UsedBookingNumbers)=" - "))"
DoCmd.RunSQL Sql_ClearNoBookingNumber
Also I tried modifying this statement to prevent Inserting the " - " .
Sql_InsertAsiaBookingNo = "INSERT INTO tblUsedBookingNumbers (UsedBookingNumbers)SELECT [Asia Booking Notice].[Booking no] FROM [Asia Booking Notice] WHERE ((([Asia Booking Notice].[Booking no])Is Not Null ))"
WHERE ((([Asia Booking Notice].[Booking no])Is Not Like " - " ))"
And again I got the same error.
Thank You for any and all feedback
Gilc
I have this same statement as a query and it runs correctly.
Data type for the "UsedBookingNumbers" fields are Text.
Users may not have a booking number at the time of entry so they add a " - " to the field for aesthetics purposes, it's using in a Email subject line.
I'm using a table to store and then lookup numbers to prevent the duplicating of booking numbers.
Because there can be a lot of " - " and I'm checking for used numbers at data entry, the user gets my message that the number has been used.
So I'm trying to delete only records with a " - ". before the user enters another record.
I've tried using the Report Close and Lost Focus Event to run the DoCmd.RunQSL but both get the same error.
SQL Code used:
Sql_ClearNoBookingNumber = "Delete tblUsedBookingNumbers.UsedBookingNumbers FROM tblUsedBookingNumbers
WHERE (((tblUsedBookingNumbers.UsedBookingNumbers)=" - "))"
DoCmd.RunSQL Sql_ClearNoBookingNumber
Also I tried modifying this statement to prevent Inserting the " - " .
Sql_InsertAsiaBookingNo = "INSERT INTO tblUsedBookingNumbers (UsedBookingNumbers)SELECT [Asia Booking Notice].[Booking no] FROM [Asia Booking Notice] WHERE ((([Asia Booking Notice].[Booking no])Is Not Null ))"
WHERE ((([Asia Booking Notice].[Booking no])Is Not Like " - " ))"
And again I got the same error.
Thank You for any and all feedback
Gilc