Sql Insert Code Not Working (Db Attached)

CharlesWhiteman

Registered User.
Local time
Today, 02:27
Joined
Feb 26, 2007
Messages
421
I'm using some Vba to record enquiries. Each enquiry may have one or more courses associated with an enquiry so I have a many to many relationship setup with associated code but when using some code to see of a course checkbox is actually cheked since then the code does not insert into the link table.

Structure:

TblEnquries (Enquries & Associated PK)

TblCourses (Contains Courses & Associated PK)

TblEnquiryCoursesLink (Contains Enquiries FK & Courses FK)

Sql code should insert into TblEnquries (And it Does) And insert into TblEnquiryCoursesLink This is where the issue lies

Any help much approciated
 

Attachments

- Spent a few minutes with it. It's not clear to me where you specify the many side of the relationship, like to create links there should be a list of things that I might choose to link to.
- Not sure how to cause the "issue"
 
Thanks for looking and your reply. I think it may have something do with the Vba code where using If and a number relaqting to whether a tick box is on or off using 0 or 1, i think that may be an issue. The code worked before albeit inserting into the link table irrespective of whether the tickbox was on or off. - I dreampt about it!!
 
I fixed it. I was using 1 and 0 where should have been using True or False. Now it works.

'Level One Interest
If Me.chkL2 = True Then
Dim VarLevel As String
VarLevel = DLookup("[CourseNameID]", "TblCourses", "[DbDescription] = 1")
Dim strSQLChkLevel As String
strSQLChkLevel = "INSERT INTO TblEnquiryCoursesLink(EnquiryIDFK, CourseIDFK)"
strSQLChkLevel = strSQLChkLevel & " VALUES(txtEnquiryID, '" & [VarLevel] & "')"
DoCmd.RunSQL strSQLChkLevel
Else
End If
 

Users who are viewing this thread

Back
Top Bottom