hi, problems with combo box and open form

  • Thread starter Thread starter reservedbcreater
  • Start date Start date
R

reservedbcreater

i want the user to select which form he wants to go to from a combo box
(the items in the combo box are the form names) and then the user clicks
Go Button(command2_click) and it goes to form they selected in the combo
box and closes current form........my code works but wont close the
current form with the combo box on it. If i put DoCMd.CLose in it it
gives me error that object doesnt exist when i click go.

If Not IsNull(cboreserve) Then
DoCMd.CLose <-------
DoCmd.OpenForm cboreserve

this is my code:

Private Sub Command2_Click()
On Error GoTo Err_Command2_Click


If Not IsNull(cboreserve) Then
DoCmd.OpenForm cboreserve

End If
Exit_Command2_Click:
Exit Sub

Err_Command2_Click:
MsgBox Err.Description
Resume Exit_Command2_Click

End Sub
 
reservedbcreater said:
i want the user to select which form he wants to go to from a combo box
(the items in the combo box are the form names) and then the user clicks
Go Button(command2_click) and it goes to form they selected in the combo
box and closes current form........my code works but wont close the
current form with the combo box on it. If i put DoCMd.CLose in it it
gives me error that object doesnt exist when i click go.

If Not IsNull(cboreserve) Then
DoCMd.CLose <-------
DoCmd.OpenForm cboreserve

this is my code:

Private Sub Command2_Click()
On Error GoTo Err_Command2_Click


If Not IsNull(cboreserve) Then
DoCmd.OpenForm cboreserve

End If
Exit_Command2_Click:
Exit Sub

Err_Command2_Click:
MsgBox Err.Description
Resume Exit_Command2_Click

End Sub

You should be able to use

If Not IsNull(cboreserve) Then
DoCmd.OpenForm cboreserve
DoCmd.Close acForm, Me.Name
End If

you could also eliminate your Go button and just put the code in
cboreserve's After Update event

HTH
Steve C
 
Back
Top