Results 1 to 7 of 7
  1. #1
    Join Date
    Apr 2011
    Posts
    12

    Unanswered: Compile error - method or data not found

    I have a "Registrants" table which includes a field titled "Registrant Master No". This field is a concatenation of first initial, last name and last four digits of phone number. Also on this form is a DOB field and after update, another field is populated to report their age as of September 1 of the current year. My goal is to have a child register for a sporting event, and based on their age (as of 01 Sep) determine if they should participate in the under 12 soccer, under 10 soccer and so on.
    I have an events table where all the summer events are entered. Dance, music, soccer etc. If soccer is chosen, then certain check boxes are enabled to determine what age group this event should be. If it is under 12 for instance - than all the other checkboxes are disabled.
    My problem arises when I want to enter the names for participants in the events. I have a junction table titled participants which has the primary key references to events and participants and I have made an entry form with events and participants as a subform. On the registrants subform, when I wish to select a person for one of my events, a combo box of all the Registrant Master No's appear and I can choose one.
    My goal as I mentioned was to determine if that particular registrant was too old for the event (i.e. his age was 13 - so he can not play under 12 soccer) and I have entered this code so far

    Code:
    Private Sub Registrant_AfterUpdate()
    If [event_type.id] = 1 And Registrant.Program_Age > 12 And (soccer.Under_12 = -1 Or soccer.Under_10 = -1 Or soccer.Under_8 = -1 Or soccer.Soccer_Skills = -1) Then
    MsgBox "too old for event"
    End If
    I would also like it to rollback and not allow the registrant to be selected - but I am not there yet.

    The compile error highlights the Program_Age field - and if I put square brackets around it or square brackets around Program.Age and drop the Registrant - another error - runtime 2465- can not find '|' referred to in your expression. Any suggestions?

  2. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Access is not always the best at highlighting the correct thing. Is this really a field name?

    [event_type.id]

    It looks like a table and field with the dot in there.
    Paul

  3. #3
    Join Date
    Apr 2011
    Posts
    12

    Compile error

    Yes, event_type is a table and event_type.id is the primary key. In an attempt to normalize the database, all of the "event types" of this recreational database are on this table. In this way, future recreational events, (i.e. music class, dance, baseball etc)can be added by a clerk. In this example, event_type.id =1 referees to soccer events in the community

  4. #4
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    If it's a table/field it should either be

    event_type.id

    or

    [event_type].[id]

    With the brackets as they are, Access thinks that's all a field.
    Paul

  5. #5
    Join Date
    Apr 2011
    Posts
    12

    Compile error - now "Runtime error 424" Object required

    I seem to be making matters worse. With the removal of the brackets - a new error "Runtime error 424" - object required now appears. It does not look like that it knows what it wants to be searching for.

  6. #6
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Are each of the fields referred to in the If clause on the form? They would need to be part of its source to do that. Plus I would disambiguate and refer to the control containing the value:

    Me.TextboxName

    Can you post the db?
    Paul

  7. #7
    Join Date
    Apr 2011
    Posts
    12

    Run time error

    No they are not on the form. I was trying to reference then by placing the table name in front of the field. I gather that you can not do that. I will need to research how to post the whole db here.

Posting Permissions

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