2

I'm trying to pass the name in a ComboBox from one form to another via button click and I cannot seem to get it to work. I am not accustomed to working with MS Access, and I'm sure its a simple answer. Here's what I have so far:

Form A:

Private Sub Command104_Click()
On Error GoTo Err_Command104_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "Vol_Hrs"
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    Forms.Vol_Hours.Search.Value = Me.Combo94.Column(0)

Exit_Command104_Click:
    Exit Sub

Err_Command104_Click:
    MsgBox Err.Description
    Resume Exit_Command104_Click

End Sub

Form B:

Private Sub cmdAddNew_Click()
On Error GoTo Err_cmdAddNew_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    DoCmd.Close

    stDocName = "frmLookupScreen"
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    Forms.frmLookupScreen.Combo94.Value = Me.Search.Column(0)

Exit_cmdAddNew_Click:
    Exit Sub

Err_cmdAddNew_Click:
    MsgBox Err.Description
    Resume Exit_cmdAddNew_Click

End Sub
Lokerim
  • 338
  • 1
  • 5
  • 21
user1902540
  • 111
  • 2
  • 12
  • Is `Froms` a typo in your actual code? If so, it should be `Forms` (switch around the `o` and `r`). – mellamokb Dec 26 '12 at 15:23
  • the errors i get are as follows A to B object does not support this property or method B to A the expression you entered referes to an object that is closed doesnt exist – user1902540 Dec 26 '12 at 15:47
  • the action or method is invalid becaise the for or report isnt bound to a table or query, is the error i get when linkcriteria is define, before the errors were as stated before in a pervious comment.. thank you – user1902540 Dec 26 '12 at 16:00

1 Answers1

0

When referencing an object ie text box use this.

Forms!FormName!ObjectName.ObjectProperty = "Testing"

When accessing Methods use this.

Forms!FormName.Form.Method.

Having said that. I find it much easier when I am using information between forms just to pull the calling forms name. Then I have access to almost all of the information on the calling form right there. I can also push data back to the calling form if necessary to update Combo or List boxes, change text, requery and so forth.

Private Sub Form_Load()

    Set frmPrevious = Screen.ActiveForm

    Me.tbText.value = frmPrevious.cbPassTest.value

End Sub

Put that code in the LOAD() of the form that you are calling then you can just pull what you need out.

Kassabba
  • 340
  • 4
  • 15