Results 1 to 8 of 8
  1. #1
    Join Date
    Oct 2011
    Posts
    6

    Question Unanswered: Open Form wth a Form

    Can someone please help me, I have been reading about this and I just don't get it. I have Access 2010. In it is a table of data, and I have already set up 20 forms to edit the database, each form named by employee name. So that part I got, and I know how to set the database so that when it is opened it shows a form of my choice.

    THIS IS WHAT I NEED
    I have a form called "Agency Rep Form. On that form is a combo box named "Rep Name" and is pulling values from the table in my database called "Agency Reps Master List. Each value in the combo box is listed once, and only one will be selected at a given time. For each value in the combo box, I have a form created already; named identically to the values in the combo box. I also have a button under the combo box named "Open Rep Form".

    I need to select a name from the combo box, and when I click the button;
    1. It opens the rep form to edit info in the data base it is linked to
    2. I need the original form "Agency Rep Form" closed

    Can someone help me with this..
    Last edited by kaeman50; 10-22-11 at 10:24.

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    The design of your database is very unusual, to say the least. Usually you create a single form, bind it to a data source and move along the rows inside of it.

    To open a form, use the Docmd.OpenForm "FormName" command. To close a form use: Docmd.Close acForm, "FormName". Both instruction have optional parameters that are explained in Access help.
    Have a nice day!

  3. #3
    Join Date
    Oct 2011
    Posts
    6
    The thing is, I have 100 people that I need to see data from the database and update it simultaneously. The request is to have these people knowing open the form with their name on it, that way they don't get confussed. It probably is not the most ideal in database world, but functionally it will satisfy the request. Each data line is marked with a persons name, and we only want the person to see / update the records with their names.

    This is what i am trying to use

    Option Compare Database
    Private Sub Combo0_EventName()
    If Combo0.Value = "Alex Rincon" Then
    DoCmd.OpenForm "Alex Rincon", , , acFormAdd, , , stLinkCriteria
    ElseIf Combo0.Value = "Cesar Mejia" Then
    DoCmd.OpenForm "Cesar Mejia", , , acFormAdd, , , stLinkCriteria
    End If
    End Sub
    Last edited by kaeman50; 10-23-11 at 11:32.

  4. #4
    Join Date
    Oct 2011
    Posts
    6
    This is what i am trying to use, but not working

    Option Compare Database
    Private Sub Combo0_EventName()
    If Combo0.Value = "Alex Rincon" Then
    DoCmd.OpenForm "Alex Rincon", , , acFormAdd, , , stLinkCriteria
    ElseIf Combo0.Value = "Cesar Mejia" Then
    DoCmd.OpenForm "Cesar Mejia", , , acFormAdd, , , stLinkCriteria
    End If
    End Sub

  5. #5
    Join Date
    Oct 2011
    Posts
    6
    I get a runtime error 424 with this code, but i dont know what it means.

    Private Sub Combo2_Change()
    If Combo0.Value = "Alex Rincon" Then
    DoCmd.OpenForm "Alex Rincon", , , acFormAdd, , , stLinkCriteria
    ElseIf Combo0.Value = "Cesar Mejia" Then
    DoCmd.OpenForm "Cesar Mejia", , , acFormAdd, , , stLinkCriteria
    End If
    End Sub

  6. #6
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Why don't you use:
    Code:
    DoCmd.OpenForm Me.Combo0.Value, , , acFormAdd ' I dropped the strCriteria parameter because
                                                  ' it seems to be undefined in the context.
    Have a nice day!

  7. #7
    Join Date
    Oct 2011
    Posts
    6
    So below is what I have last used, and I am getting a compile error systax error message. I feel I am close, what am I doing wrong.

    Private Sub Combo2_Change()
    If Combo0.Value = "Alex Rincon" Then
    DoCmd.OpenForm Me.Combo0."Alex Rincon", , , acFormAdd
    ElseIf Combo0.Value = "Cesar Mejia" Then
    DoCmd.OpenForm Me.Combo0."Cesar Mejia", , , acFormAdd
    End If
    End Sub

  8. #8
    Join Date
    Aug 2011
    Location
    Indianapolis, IN, USA
    Posts
    41
    I think you need another comma before acFormAdd. You are putting acFormAdd in the Where argument instead of the DataMode argument.

Posting Permissions

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