• ‘Global’ Event (2000)

    Author
    Topic
    #401193

    I have a database for a motor bike racing club. There will be a number of events (meetings) during the year and I think I have set these up properly. Many reports will be necessary for each event/meeting eg Riders Details, sidecar entrants details, costings, scrutineers etc. and thewe will be up to 10 races per meeting
    I would like to be able to choose a particular event/meeting and have it be the default event for all reports/queries till changed eg All reports etc will be for Eastern Creek Raceway, meeting 2 Round 1 until I tell it otherwise. I envisage this data being part of the queries needed to produce the reports etc but dont know how to do this – Any assistance greatly appreciated

    Viewing 1 reply thread
    Author
    Replies
    • #788469

      Assuming that you have a unique ID for each event, and that this is a number (Iong integer), you could do something like this:

      • In a standard module (the type you create by clicking New in the Modules section of the database window), enter the following code:

        Public DefaultEventID As Long

        Public Sub SetDefaultEventID()
        DefaultEventID = Val(InputBox(“Enter default Event ID”))
        End Sub

        Public Function GetDefaultEventID() As Long
        GetDefaultEventID = DefaultEventID
        End Function

      • In queries that should return only data for the default event, set the criteria for the event ID field to

        GetDefaultEventID()

      • To prompt the user for another default event, run SetDefaultEventID, or (more user-friendly) create a form for this.
        [/list]HTH
      • #788619

        Never sure of the ettiquete here- waste of bandwith by saying thank you vs rudeness by not – screw it – Thank you very much – it really is appreciated

        • #788621

          A (short) reaction is always appreciated. If the original poster doesn’t react to a reply at all, it isn’t clear to the Lounger who replied (and to others reading the thread) if the reply was useful.

        • #788622

          A (short) reaction is always appreciated. If the original poster doesn’t react to a reply at all, it isn’t clear to the Lounger who replied (and to others reading the thread) if the reply was useful.

      • #788620

        Never sure of the ettiquete here- waste of bandwith by saying thank you vs rudeness by not – screw it – Thank you very much – it really is appreciated

      • #810217

        Hans – havent touched this for a while but I must be doing something wrong.
        I created the module as instructed with slight changes to reflect me using MeetingID rather than EventID in my Tables
        The module is :
        Option Compare Database

        Public DefaultMeetingID As Long

        Public Sub SetDefaultMeetingID()
        DefaultMeetingID = Val(InputBox(“Enter default Meeting ID”))
        End Sub

        Public Function GetDefaultMeetingID() As Long
        GetDefaultMeetingID = DefaultMeetingID
        End Function

        This has a heading on the module screen (see how out of depth I am – I’m not even sure of the terms) of General on the left and GetDefaultMeetingID on the right
        I’m then lost as to what to do from here. If I open up the modules section of Access and double click on the module, it opens up this module and takes me to just after the end function section.
        I then tied the module to a macro that does nothing but OpenModule using the getmeetingdefaultid module, in the hope I could link the macro to a button on a form – Seems to do nothing but take me to the end of the module and leave me in “module edit mode”. My meetingID field is an autonumber if that makes any difference

        I’m sure this is something simple like me formatting something wrongly but I cant see where its wrong
        Appreciate any help

        Steve

        • #810386

          The dropdown in the top left corner of a module window shows the object to which the code containing the insertion point belongs. Since the code you created does not belong to a particular object, this dropdown displays “General”. The dropdown in the top right corner shows the name of the procedure or function containing the insertion point.

          You don’t need the macro; as you found, it won’t do anything useful.

          If you want the user to be able to enter the new default Meeting ID, you must create a form for it. Place a command button on the form, and call SetDefaultMeetingID in the On Click code of this command button. Say that the command button is named cmdNewID:

          – With the form in design view, select cmdNewID
          – Activate the Event tab of the Properties window.
          – Click in the On Click event.
          – Select [Event Procedure] from the dropdown list.
          – Click the … to the right of the dropdown arrow.
          – Make the code look like this:

          Private Sub cmdNewID_Click()
          SetDefaultMeetingID
          End Sub

          To use the default meeting ID, create a query based on the table or tables you need. Include MeetingID in the query grid, and enter

          GetDefaultMeetingID()

          in the Criteria line for this column. This will make the query return only records with the specified MeetingID. Use the query as record source for forms and reports.

          • #810398

            Tried that – getting ‘Compile Error: Expected Variable or procedure, not module and pointing at the SetDefaultMeetingID line

            • #810418

              Did you name the module SetMeetingID too? If so, that confuses Access, since it is also the name of a procedure. Give the module another name.

            • #810484

              Got there – thanks very very much
              Steve

            • #810485

              Got there – thanks very very much
              Steve

            • #810419

              Did you name the module SetMeetingID too? If so, that confuses Access, since it is also the name of a procedure. Give the module another name.

          • #810399

            Tried that – getting ‘Compile Error: Expected Variable or procedure, not module and pointing at the SetDefaultMeetingID line

        • #810387

          The dropdown in the top left corner of a module window shows the object to which the code containing the insertion point belongs. Since the code you created does not belong to a particular object, this dropdown displays “General”. The dropdown in the top right corner shows the name of the procedure or function containing the insertion point.

          You don’t need the macro; as you found, it won’t do anything useful.

          If you want the user to be able to enter the new default Meeting ID, you must create a form for it. Place a command button on the form, and call SetDefaultMeetingID in the On Click code of this command button. Say that the command button is named cmdNewID:

          – With the form in design view, select cmdNewID
          – Activate the Event tab of the Properties window.
          – Click in the On Click event.
          – Select [Event Procedure] from the dropdown list.
          – Click the … to the right of the dropdown arrow.
          – Make the code look like this:

          Private Sub cmdNewID_Click()
          SetDefaultMeetingID
          End Sub

          To use the default meeting ID, create a query based on the table or tables you need. Include MeetingID in the query grid, and enter

          GetDefaultMeetingID()

          in the Criteria line for this column. This will make the query return only records with the specified MeetingID. Use the query as record source for forms and reports.

      • #810218

        Hans – havent touched this for a while but I must be doing something wrong.
        I created the module as instructed with slight changes to reflect me using MeetingID rather than EventID in my Tables
        The module is :
        Option Compare Database

        Public DefaultMeetingID As Long

        Public Sub SetDefaultMeetingID()
        DefaultMeetingID = Val(InputBox(“Enter default Meeting ID”))
        End Sub

        Public Function GetDefaultMeetingID() As Long
        GetDefaultMeetingID = DefaultMeetingID
        End Function

        This has a heading on the module screen (see how out of depth I am – I’m not even sure of the terms) of General on the left and GetDefaultMeetingID on the right
        I’m then lost as to what to do from here. If I open up the modules section of Access and double click on the module, it opens up this module and takes me to just after the end function section.
        I then tied the module to a macro that does nothing but OpenModule using the getmeetingdefaultid module, in the hope I could link the macro to a button on a form – Seems to do nothing but take me to the end of the module and leave me in “module edit mode”. My meetingID field is an autonumber if that makes any difference

        I’m sure this is something simple like me formatting something wrongly but I cant see where its wrong
        Appreciate any help

        Steve

    • #788470

      Assuming that you have a unique ID for each event, and that this is a number (Iong integer), you could do something like this:

      • In a standard module (the type you create by clicking New in the Modules section of the database window), enter the following code:

        Public DefaultEventID As Long

        Public Sub SetDefaultEventID()
        DefaultEventID = Val(InputBox(“Enter default Event ID”))
        End Sub

        Public Function GetDefaultEventID() As Long
        GetDefaultEventID = DefaultEventID
        End Function

      • In queries that should return only data for the default event, set the criteria for the event ID field to

        GetDefaultEventID()

      • To prompt the user for another default event, run SetDefaultEventID, or (more user-friendly) create a form for this.
        [/list]HTH
    Viewing 1 reply thread
    Reply To: ‘Global’ Event (2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: