Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2013
    Posts
    7

    Unanswered: Custom error message

    I am trying to replace the default error message

    "Run-time error 3075
    Syntax error (missing operator) in query expression 'Courses.CourseID ='."

    with

    "Select and Date and Activity then add Attendees"

    This error appears if the operator has not selected a Date in the form header before adding Attendees to the form.

    I am running Access 2007


    Steve

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    so check the user has entered a value
    IR, better yet, only allow the user to run the query if they have selected a value/all values (lock/disable a command button until selected).
    but in the absence of your code its tricky to help further
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Apr 2013
    Posts
    7
    The button which if selected without a date been added is "Add Atendees" button with the code:

    Private Sub cmdAddAttendees_Click()

    Dim strSQL As String

    strSQL = "INSERT INTO [Contact Attendance] ( CourseID, [Contact ID] ) " & _
    "SELECT Courses.CourseID, Contacts.[Contact ID] " & _
    "FROM Courses, Contacts " _
    "WHERE Courses.CourseID = " & Me.cboCourse

    CurrentDb.Execute strSQL, dbFailOnError

    Me.Requery

    End Sub


    What would I need to add to check if there was data in cboCourse?

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    if it were me
    working on the design paradigm that a user should not be able to do anything harmful or do stuff unless all the pre cursors are in place, then
    looking at your query I don't see how date comes into it, the query refers only to a selected courseid from the combo box.
    1) I'd disable the button unless you have valid data. (so that means in the forms on current event
    2) in the combobox afterupdate event I'd enable the the button

    OR
    leave your form as is, but add some code that checks there is a value in the combo box
    so that will be something like:-
    Code:
    Dim strSQL As String
    if Not IsNull(Me.cboCourse.value ) then
      strSQL = "INSERT INTO [Contact Attendance] ( CourseID, [Contact ID] ) " & _
    to be hones that maynot work, you mya need to examine the combobox properties to fidn the correct item
    it could be the .elected collection, or the .text property. It depends on how the combo is defined/used.
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •