Hi all,
I have a command button that I want to look at the table 'ImportEquipment' and find out whether [CodeNo] from the table 'PoolBookings' exists in both.
If this CodeNo exists, then I want to change the [Location] field in the 'ImportEquipment' table to Me.DepartmentBookingOut
At the moment it is highlights my strsql as the error and I am getting a 'Too few parameters. Expected 1.'
The [Code No] field that exists in 'ImportEquipment', has a space in the Code No as this was created many years ago by somebody else and I've not yet got round to changing this and all of the code relating to this. I understand that if a field has a space, then it must have brackets around it, so maybe I've done this wrong.
There must be something wrong with the strSql = "SELECT * FROM [ImportEquipment] WHERE ([Code No]) = " & Me.CodeNo & ""
But I can't figure out what this is.
The full code is below.
Thanks all in advance
I have a command button that I want to look at the table 'ImportEquipment' and find out whether [CodeNo] from the table 'PoolBookings' exists in both.
If this CodeNo exists, then I want to change the [Location] field in the 'ImportEquipment' table to Me.DepartmentBookingOut
At the moment it is highlights my strsql as the error and I am getting a 'Too few parameters. Expected 1.'
The [Code No] field that exists in 'ImportEquipment', has a space in the Code No as this was created many years ago by somebody else and I've not yet got round to changing this and all of the code relating to this. I understand that if a field has a space, then it must have brackets around it, so maybe I've done this wrong.
There must be something wrong with the strSql = "SELECT * FROM [ImportEquipment] WHERE ([Code No]) = " & Me.CodeNo & ""
But I can't figure out what this is.
The full code is below.
Code:
Dim db As DAO.Database
Dim REC As Recordset
Dim strSql As String
Dim n As Integer
Dim TotalRecords As Integer
TotalRecords = DCount("CodeNo", "ImportEquipment", "([Code No]) = '" & Me.CodeNo & "'")
If TotalRecords > 0 Then
'Update PoolBookings with Returns Information
strSql = "SELECT * FROM [ImportEquipment] WHERE ([Code No]) = " & Me.CodeNo & ""
Set db = CurrentDb()
Set REC = db.OpenRecordset(strSql, dbOpenDynaset)
REC("Location") = Me.DepartmentBookingOut
Else
Message = "No Record Found"
End If
DoCmd.Close acForm, "PoolBookings"
Thanks all in advance