Bookings ID is number
ID is autonumber
Error says:
Run-Time error '2471':
The expression you entered as a query parameter produced this error: '[Bookings ID]' - If DCount("[Click ID]", "Access Click log", "[Bookings ID] = " & Forms![Roll Out CRM]![Royal Rollout AM Routes]![ID]) = 0 Then
Thank you for the help!
Vasago
Look at two things:
-- Open the table "Access Click log" where[Bookings ID] is located.
Check that the field name is spelled correctly between the code and the table.
-- Check the type cast of the [Bookings ID] field, I suspect it is set to "text" not numeric as you are expecting.
8 6346
If booking id is a string, you will need to surround the value you're looking for in quotes.
Booking ID's type is a number along with ID
Then you will need to post the full exact error message.
zmbd 5,501
Expert Mod 4TB
- The string theory:
You've stumbled upon one of my pet peeves by building the criteria string within the command - and it's not your fault because that's how a majority of examples show how to use the command.
Instead I suggest that you build the string first and then use the string in the command. Why you might ask, because you can then check how the string is actually resolving; thus, making troubleshooting the code so much easier as most of the time the issue is with something missing or not resolving properly/as expected within your string.
So to use your code: -
'>The following is air code; thus, not tested and may require more effort to operate properly
-
'
-
DIM strSQL as string
-
Dim intCount As Integer
-
'
-
'
-
strSQL = "[Bookings ID] = " & _
-
Forms![Roll Out CRM]![Royal Rollout AM Routes]![ID]
-
'
-
'now you can insert a debug print here for troubleshooting
-
' - press <ctrl><g> to open the immediate window
-
' - you can now cut and paste this information for review!
-
'
-
debug.print "Your criteria = " & strSQL
-
'
-
'now use the string in your code:
-
intCount= DCount("[Click ID]", "Access Click log", strSQL)
-
debug.print "Your Count= " & intCount
-
'
-
'Note: I didn't return the count within the IF...THEN...
-
'once again because troubleshooting the code is not easily
-
'done when the function returns within another
-
'function/statement.
-
'
-
'
-
if intCount = 0 then
-
'the remaining code
-
end if
-
'
-
'
If you will make these little changes and post back the resolved string we can help you tweak the code.
When posting errors:
Please post the EXACT title, number, and text of the error message. Please do not alter, omit, nor abreviate the information provided in the error message. ALSO indicate on which line of the code the error occurs and provide enough code so that we have the context of the commands used.
ZMBD,
I can't thank you enough for you time, education and knowledge. I have included the code below. My debug print for strSQL is Your criteria = Bookings ID = 2110. This is the correct Booking ID number.
Error Code on line 9:
Run-time error '2471':
The expression you entered as a query parameter produced this error: '[Bookings ID]' - Private Sub Form_AfterInsert()
-
Dim db As Recordset
-
Dim strSQL As String
-
Dim intCount As Integer
-
-
strSQL = "[Bookings ID] = " & _
-
Forms![Roll Out CRM]![Royal Roll out Field Trips]![ID]
-
Debug.Print "Your criteria = " & strSQL
-
intCount = DCount("[Click ID]", "Access Click log", strSQL)
-
Debug.Print "Your Count= " & intCount
-
If intCount = 0 Then
-
Set db = CurrentDb.OpenRecordset("SELECT * FROM [Access click Log]")
-
db.AddNew
-
db![Booking ID] = ID
-
db.Update
-
End If
Zmbd,
I can't thank you enough for you time, lesson, and knowledge. My debug print for strSQL is Your criteria = [Bookings ID] = 2113. This is the correct Bookings ID.
I am getting the error below on line 9.
Error:
Run-time error '2471':
The expression you entered as a query parameter produced this error: '[Bookings ID]' -
Private Sub Form_AfterInsert()
-
Dim db As Recordset
-
Dim strSQL As String
-
Dim intCount As Integer
-
-
strSQL = "[Bookings ID] = " & _
-
Forms![Roll Out CRM]![Royal Roll out Field Trips]![ID]
-
Debug.Print "Your criteria = " & strSQL
-
intCount = DCount("[Click ID]", "Access Click log", strSQL)
-
Debug.Print "Your Count= " & intCount
-
If intCount = 0 Then
-
Set db = CurrentDb.OpenRecordset("SELECT * FROM [Access click Log]")
-
db.AddNew
-
db![Booking ID] = ID
-
db.Update
-
End If
zmbd 5,501
Expert Mod 4TB
Look at two things:
-- Open the table "Access Click log" where[Bookings ID] is located.
Check that the field name is spelled correctly between the code and the table.
-- Check the type cast of the [Bookings ID] field, I suspect it is set to "text" not numeric as you are expecting.
ZMBD,
Thank you again for your help. Problem is solved and I feel extremely embarrassed. [Bookings ID] is suppose to be [Booking ID].
Thank you,
Vasago
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Bill Patel |
last post by:
I am getting Runtime error on line 50. Please Help.
Thank You
Bill
1 <%@ Page Language="VB" %>
2 <%@ import Namespace="System.Data" %>
3 <%@ import Namespace="System.Data.SqlClient"...
|
by: Pat |
last post by:
In my Web.config i have :-
<customErrors mode="On" defaultRedirect="genericerror.htm">
<error statusCode="404" redirect="pagenotfound.aspx"/>
</customErrors
to get page not found error but...
|
by: joswell |
last post by:
Need a little help please! I am getting runtime error 3001 at oRS.filter = ("RM TYP = '" & cell.Text & "'")
Private Sub CommandButton5_Click()
Application.ScreenUpdating =...
|
by: ruvi |
last post by:
I am getting runtime error 3021 - Either EOF or BOF is true or the current record has been deleted.....
I have 2 combo boxes in a form- One for the client and the other for the project.
When the...
|
by: opie |
last post by:
I created this program on Vista using VB 6.0 with Access as the DB. When I created the executable and was trying to use it, on a XP machine, it gave me two issues. The first problem was it was...
|
by: Lauren Dobson |
last post by:
This database was working days ago, outputting a vocabulary list into a word document. Any idea why I'm getting runtime error 3010? I just switched from Windows XP to Windows 7 but I'm still using...
|
by: creation |
last post by:
$b= 1;
while($b)
{
$a = <>;
if($a eq 42)
break;
else
{
print $a;
}
|
by: mishika |
last post by:
Q: getting runtime error 52 bas file name or number
D:Public Function gf_ChkMkDir(iDirPath As String, iDirName As String) As Boolean
Dim MyPath As String
gf_ChkMkDir = False
MyPath =...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |