Hildegoat15
Technical User
hi,
once agan i've stumped myself. i have a popup form that allows a user to enter a new City Code, City Name, and Province, and i'm trying to check for duplicates. my check for city code works fine, but when i check for duplicate city name/province combination, i get the error "No value given for one or more required parameters." the error is at the second rst.open line in the below code:
'Search for duplicate City Code. If a duplicate is not found, let the user continue; otherwise
' issue a messagebox and set focus to the City Code field
Set rst = New ADODB.Recordset
strQuery = "SELECT * FROM [Sleep - City Codes] WHERE str([CityCode]) = " _
& Me!txtCityCode & ""
rst.Open strQuery, CurrentProject.Connection, adOpenKeyset
If rst.BOF = True And rst.EOF = True Then
rst.close
Set rst = Nothing
'Searches for duplicate City/Province combination. If a duplicate is not found, continue;
' otherwise issue a messagebox and set focus to City Name field
Set rst = New ADODB.Recordset
strQuery = "SELECT * FROM [Sleep - City Codes] WHERE [CityName] = " _
& StrConv(Me!txtCityName, vbProperCase) & " AND [Province] = " _
& Me!txtProvince & ""
rst.Open strQuery, CurrentProject.Connection, adOpenKeyset
If rst.BOF = True And rst.EOF = True Then
rst.close
Set rst = Nothing
etc....
it seems like exactly the same syntax, except for a different SQL query. can anyone help me? -Matt
once agan i've stumped myself. i have a popup form that allows a user to enter a new City Code, City Name, and Province, and i'm trying to check for duplicates. my check for city code works fine, but when i check for duplicate city name/province combination, i get the error "No value given for one or more required parameters." the error is at the second rst.open line in the below code:
'Search for duplicate City Code. If a duplicate is not found, let the user continue; otherwise
' issue a messagebox and set focus to the City Code field
Set rst = New ADODB.Recordset
strQuery = "SELECT * FROM [Sleep - City Codes] WHERE str([CityCode]) = " _
& Me!txtCityCode & ""
rst.Open strQuery, CurrentProject.Connection, adOpenKeyset
If rst.BOF = True And rst.EOF = True Then
rst.close
Set rst = Nothing
'Searches for duplicate City/Province combination. If a duplicate is not found, continue;
' otherwise issue a messagebox and set focus to City Name field
Set rst = New ADODB.Recordset
strQuery = "SELECT * FROM [Sleep - City Codes] WHERE [CityName] = " _
& StrConv(Me!txtCityName, vbProperCase) & " AND [Province] = " _
& Me!txtProvince & ""
rst.Open strQuery, CurrentProject.Connection, adOpenKeyset
If rst.BOF = True And rst.EOF = True Then
rst.close
Set rst = Nothing
etc....
it seems like exactly the same syntax, except for a different SQL query. can anyone help me? -Matt