Results 1 to 4 of 4
  1. #1
    exeTrix is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Apr 2011
    Posts
    4

    Passing Data Between Forms


    Hi All!

    I'm new to Access so you'll have to bare with my limited and somewhat noobish understanding of the product.

    I have a form that a user fills in to add a event to a database which works fine What I would like to know is how to add a command button that will open another form to show people that may wish to attend the event.

    I have some VB.Net knowledge and from this I know that you can set the buttons visibility based upon an if statement like below:

    Code:
    If SomeVar Then
    btnUpdate.Visible = true
    End If
    So running off the back of that I wanted to show the command button if the record has been saved then pass the day the event is to another form so when the user clicks the button they have a list of all people who may be able to attend.

    Unfortunately, I'm unable to find out how to do this on the net. My experience is predominantly internet programming so I'm a bit lost and don't know where to start.

    Any help would be greatly appreciated.

  2. #2
    exeTrix is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Apr 2011
    Posts
    4
    Ok I think I've managed to find something useful on the net with regards to checking if the form has been saved:

    Code:
    If Me.Dirty Then
    'show the button - however that may be 
    End If
    Would this go into a equivalent of Page Load found in web development? Then I need to pass the Day to my second form and somehow use it to display the correct records - maybe with DLookup() function.

    Sorry if I'm well off the mark i don't really understand how Access deals with events nor do I really know how forms work in the background in preparing the output.

  3. #3
    exeTrix is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Apr 2011
    Posts
    4
    Hope somebody can help me. I think I was barking up the wrong tree earlier. I have managed to create a form based upon an SQL query let call it FormA. So when the form is opened it asks for the user to enter a day, then displays all matches.

    What I want is to put some kind of control on another form so that when it's clicked the user is taken to FormA but the day is passed to it automatically.

    Hope that makes sense. If anybody could help with this it's be great

  4. #4
    exeTrix is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Apr 2011
    Posts
    4
    Did it myself. Thanks for all the help lol

    Just in case anybody comes across this here's what I did. Might not be right but it was the best I could do....

    Code:
    Private Sub btnFindVolunteer_Click()
        'assign the variables
        Dim MyDB As DAO.Database
        Dim qdef As DAO.QueryDef
        Dim strSQL As String
        Dim Day As String
        
        'pull the day from the form
        Day = Me.Day
    
        'let the engine know which database to use
        Set MyDB = CurrentDb()
        
        'here's the SQL we need to use
        strSQL = "SELECT Volunteer.Title, Volunteer.ForeName, Volunteer.FamilyName, Volunteer.PhoneNo " & _
                 "FROM Volunteer INNER JOIN Availability ON Volunteer.VolunteerID = Availability.VolunteerId " & _
                 "WHERE (((Availability.Day)= '" & Day & "') AND ((Volunteer.CRBCheckDate) Is Not Null))"
        
        'delete the old query :)
        MyDB.QueryDefs.Delete "FindEventVolunteer"
        
        'now recreate the query
        Set qdef = MyDB.CreateQueryDef("FindEventVolunteer", strSQL)
    
        'Open the query and display to the user
        DoCmd.OpenQuery "FindEventVolunteer", acViewNormal
    
    End Sub

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Passing Data from on Form to Another..
    By ETCallHome in forum Forms
    Replies: 2
    Last Post: 03-12-2011, 12:26 AM
  2. PASSING Values between Forms
    By chhinckley in forum Programming
    Replies: 1
    Last Post: 08-27-2010, 10:19 AM
  3. Form not passing data to query
    By bobfin in forum Queries
    Replies: 13
    Last Post: 08-11-2010, 05:28 AM
  4. Passing Data with OpenForm
    By nkenney in forum Forms
    Replies: 1
    Last Post: 10-26-2009, 11:40 AM
  5. Replies: 3
    Last Post: 06-02-2009, 09:51 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums