Results 1 to 9 of 9
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Now-Luanda, Angola, Originally - Anna Bay, New South Wales, Australia
    Posts
    238
    Thanks
    0
    Thanked 0 Times in 0 Posts

    'Global' Event (2000)

    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
    Dummy from Down Under <img src=/S/flags/Australia.gif border=0 alt=Australia width=30 height=18>

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: 'Global' Event (2000)

    Assuming that you have a unique ID for each event, and that this is a number (Iong integer), you could do something like this:
    <UL><LI>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

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

    GetDefaultEventID()

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

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Now-Luanda, Angola, Originally - Anna Bay, New South Wales, Australia
    Posts
    238
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: 'Global' Event (2000)

    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
    Dummy from Down Under <img src=/S/flags/Australia.gif border=0 alt=Australia width=30 height=18>

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: 'Global' Event (2000)

    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.

  5. #5
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Now-Luanda, Angola, Originally - Anna Bay, New South Wales, Australia
    Posts
    238
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: 'Global' Event (2000)

    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
    Dummy from Down Under <img src=/S/flags/Australia.gif border=0 alt=Australia width=30 height=18>

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: 'Global' Event (2000)

    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.

  7. #7
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Now-Luanda, Angola, Originally - Anna Bay, New South Wales, Australia
    Posts
    238
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: 'Global' Event (2000)

    Tried that - getting 'Compile Error: Expected Variable or procedure, not module and pointing at the SetDefaultMeetingID line
    Dummy from Down Under <img src=/S/flags/Australia.gif border=0 alt=Australia width=30 height=18>

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: 'Global' Event (2000)

    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.

  9. #9
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Now-Luanda, Angola, Originally - Anna Bay, New South Wales, Australia
    Posts
    238
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: 'Global' Event (2000)

    Got there - thanks very very much
    Steve
    Dummy from Down Under <img src=/S/flags/Australia.gif border=0 alt=Australia width=30 height=18>

Posting Permissions

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