LawrenceHill1
New member
- Local time
- Today, 00:00
- Joined
- Sep 20, 2018
- Messages
- 2
Help please.
I am using Access 2016 as part of Office 365 with a database in the accdb file format of 2007-2016.
On one form I can get dlookup to work but another I cannot. I know it is something to do with the variable types and the corresponding syntax i'm using, but I just cant find a solution.
When
My form field Forms![frmaddintschedcourse].[CourseTitle] is a defined as dropdown box with a control source from my table field which is defined as 'short text' because it ultimately points back to owning table's primary key which is also defined as short text... i.e. [tblcourse].[CourseTitle]
This code is working absolutely fine.
Me.Duration = DLookup("[CourseDuration]", "[tblcourse]", "[CourseTitle] = Forms![frmaddintschedcourse].[CourseTitle]")
BUT
My form field Forms![frmaddintbooking].[CourseTitle] is a defined as dropdown box with a control source from my table field which is defined as a number (long integer) because it ultimately point back to owning table's primary key which is an autonumber..... i.e [tblintschedcourse].[InternalScheduledCourseID]
This code
Me.CoursePrice = DLookup("[CoursePrice]", "[tblintschedcourse]", "[InternalScheduledCourseID] = Forms![frmaddintbooking].[CourseTitle]")
generates the error 2471 The expression you entered as a query parameter produced this error 'Forms![frmaddintbooking].[CourseTitle]'
When I change it to this code
Me.CoursePrice = DLookup("[CoursePrice]", "[tblintschedcourse]", "[InternalScheduledCourseID] = '" & Forms![frmaddintbooking].[CourseTitle] & "'")
it generates the error 2465 Microsoft Access can't find the field "|" referred to in your expression"
For clarification I have also tried this code
Me.CoursePrice = DLookup("[CoursePrice]", "[tblintschedcourse]", [InternalScheduledCourseID] = Forms![frmaddintbooking].[CourseTitle])
and it also generates the error 2465 as above
Any ideas please.
I am using Access 2016 as part of Office 365 with a database in the accdb file format of 2007-2016.
On one form I can get dlookup to work but another I cannot. I know it is something to do with the variable types and the corresponding syntax i'm using, but I just cant find a solution.
When
My form field Forms![frmaddintschedcourse].[CourseTitle] is a defined as dropdown box with a control source from my table field which is defined as 'short text' because it ultimately points back to owning table's primary key which is also defined as short text... i.e. [tblcourse].[CourseTitle]
This code is working absolutely fine.
Me.Duration = DLookup("[CourseDuration]", "[tblcourse]", "[CourseTitle] = Forms![frmaddintschedcourse].[CourseTitle]")
BUT
My form field Forms![frmaddintbooking].[CourseTitle] is a defined as dropdown box with a control source from my table field which is defined as a number (long integer) because it ultimately point back to owning table's primary key which is an autonumber..... i.e [tblintschedcourse].[InternalScheduledCourseID]
This code
Me.CoursePrice = DLookup("[CoursePrice]", "[tblintschedcourse]", "[InternalScheduledCourseID] = Forms![frmaddintbooking].[CourseTitle]")
generates the error 2471 The expression you entered as a query parameter produced this error 'Forms![frmaddintbooking].[CourseTitle]'
When I change it to this code
Me.CoursePrice = DLookup("[CoursePrice]", "[tblintschedcourse]", "[InternalScheduledCourseID] = '" & Forms![frmaddintbooking].[CourseTitle] & "'")
it generates the error 2465 Microsoft Access can't find the field "|" referred to in your expression"
For clarification I have also tried this code
Me.CoursePrice = DLookup("[CoursePrice]", "[tblintschedcourse]", [InternalScheduledCourseID] = Forms![frmaddintbooking].[CourseTitle])
and it also generates the error 2465 as above
Any ideas please.