R
Robin
Hello,
I'm haveing a problem getting this to work. I have a Main form on which
there is a listbox populated with a client list and a New Client (bMain1)
button. If I Double Click on a client in the listbox, I want the Client form
to open to that record. If I Click on the New Client (bMain1) button I want
the same form to open to a new record.
Is there some "standard" way to open a form and let the form know from where
it was called? I've already used the OpenArgs to pass a UserID from form to
form.
I've tried the following:
On the Main form:
Private Sub bMain1_Click()
If Me.bMain1.Caption = "New Client" Then
stDocName = "fmClient"
DoCmd.OpenForm stDocName, , , , acFormAdd, , stUserID
ElseIf Me.bMain1.Caption = "New Engagement" Then
etc...
AND
Private Sub lstCMainC_DblClick(Cancel As Integer)
Dim stDocName As String
Dim stLinkCriteria As String
Dim stUserID As String
stDocName = "fmClient"
stUserID = Me.vUserID
stLinkCriteria = "[ClientID]=" & "'" & Me![lstCMainC] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria, , , stUserID
On the Client form:
Private Sub Form_Open(Cancel As Integer)
Dim stUserID As String
Me.vUserID = Me.OpenArgs
Select Case Me.Form.DataEntry
Case True
Me.Form.Caption = "ADD NEW CLIENT"
Me.bNewCancel.Caption = "Cancel"
Me.bEditSave.Caption = "Save"fmClientUnlockControls
fmClientDisableButtons
etc...
Case False
Me.Form.Caption = "CLIENT DETAILS"
Me.bNewCancel.Caption = "New"
Me.bEditSave.Caption = "Edit"
fmClientLockControls
fmClientEnableButtons
Case Else
End Select
This ALWAYS triggers the Case True with its resulting code. It used to work
before I added the capability to add a new client. (Used to be just Dbl
Clicking list opened the form to the correct record.)
Also, as you see above, I've set a button to Cancel when opened to Add a
record so the user can cancel an Add if they desire but that doesn' work
either. (Object doesnt support property or method error)
If Me.Dirty = True Then
Me.Undo
fmClientLockControls
fmClientEnableButtons
DoCmd.Close acForm
End If
Thank you for any help,
Robin
I'm haveing a problem getting this to work. I have a Main form on which
there is a listbox populated with a client list and a New Client (bMain1)
button. If I Double Click on a client in the listbox, I want the Client form
to open to that record. If I Click on the New Client (bMain1) button I want
the same form to open to a new record.
Is there some "standard" way to open a form and let the form know from where
it was called? I've already used the OpenArgs to pass a UserID from form to
form.
I've tried the following:
On the Main form:
Private Sub bMain1_Click()
If Me.bMain1.Caption = "New Client" Then
stDocName = "fmClient"
DoCmd.OpenForm stDocName, , , , acFormAdd, , stUserID
ElseIf Me.bMain1.Caption = "New Engagement" Then
etc...
AND
Private Sub lstCMainC_DblClick(Cancel As Integer)
Dim stDocName As String
Dim stLinkCriteria As String
Dim stUserID As String
stDocName = "fmClient"
stUserID = Me.vUserID
stLinkCriteria = "[ClientID]=" & "'" & Me![lstCMainC] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria, , , stUserID
On the Client form:
Private Sub Form_Open(Cancel As Integer)
Dim stUserID As String
Me.vUserID = Me.OpenArgs
Select Case Me.Form.DataEntry
Case True
Me.Form.Caption = "ADD NEW CLIENT"
Me.bNewCancel.Caption = "Cancel"
Me.bEditSave.Caption = "Save"fmClientUnlockControls
fmClientDisableButtons
etc...
Case False
Me.Form.Caption = "CLIENT DETAILS"
Me.bNewCancel.Caption = "New"
Me.bEditSave.Caption = "Edit"
fmClientLockControls
fmClientEnableButtons
Case Else
End Select
This ALWAYS triggers the Case True with its resulting code. It used to work
before I added the capability to add a new client. (Used to be just Dbl
Clicking list opened the form to the correct record.)
Also, as you see above, I've set a button to Cancel when opened to Add a
record so the user can cancel an Add if they desire but that doesn' work
either. (Object doesnt support property or method error)
If Me.Dirty = True Then
Me.Undo
fmClientLockControls
fmClientEnableButtons
DoCmd.Close acForm
End If
Thank you for any help,
Robin