OpenArgs Statement

WillJ

Registered User.
Local time
Today, 21:14
Joined
Oct 20, 2012
Messages
40
Hi Guys & Girls,:banghead:

Thanks in advance for your help.

I presently have this problem. I have a reminders form that Opens from a variety of different forms, for arguments sake let's say Production and Meeting both have a button with an OnClick events then leads to the following line of code;

Code:
DoCmd.OpenForm "frmEmail", , , , acFormAdd, , Me.[ProductionID]
Code:
DoCmd.OpenForm "frmEmail", , , , acFormAdd, , Me.[MeetingID]

The problem occurs when I have the
Code:
Private Sub Form_Load()
If Not IsNull(Me.OpenArgs) Then
  DoCmd.GoToRecord , , acNewRec
  Me.[ProductionID] = Me.OpenArgs
End If
End Sub

I want the OpenArgs to be variable to allow for the correct ID to be dropped in the relevant combo box. I have tried;

Code:
Private Sub Form_Load()
If Not IsNull(Me.OpenArgs) Then
  DoCmd.GoToRecord , , acNewRec
  Me.[ProductionID] = Me.OpenArgs
Me.[MeetingID] = Me.OpenArgs
End If
End Sub

Addmitedlty, the logic dosen't work forme I would have to write another statement however I've spent to long dumbfounded and was hoping you guys & girls could give me a little help.

Many Thanks,

Will
 
WillJ, you have shown what you have done, but you have not in full essence explained what you are trying to do.

What exactly do you mean when you say you want the OpenArgs to be a variable?
 
Hi pr2-eugin;

What I am trying to do is pass an ID field to another field in another form.
I have used an OpenArgs statement which works fine when I only transfer one or more values from the same form.
What I am want to be able to do is allow a user who clicks from the Sales form on the call button to have the sales id transferred to the relevant field in the call form. I also would like production to transfer the production id when they click through to the call form (same form).
The problem comes with the OpenArgs statement being only from one form.

Hi pBaldy,

I tried your suggestion but it dosen't allow for access to the calls form from other forms;

Is there anyway I could add a further rule to
Code:
If Not IsNull(Me.OpenArgs) Then
    Me.ProductionID = Me.OpenArgs
    Else
    Me.SalesID = Me.OpenArgs
End If
End Sub

By If
Code:
Me.OpenArgs = Me.ProductionID Then 
Me.OpenArgs = Me.ProductionID
Else
Me.OpenArgs = Me.SalesID
End If
End Sub

I'm basically trying to tell the computer that is should match the OpenArgs statement to the relevant field.
 
If OpenArgs is just a number, how are you to tell which field it's from, unless they are so different the range would tell you? I don't know what "it dosen't allow for access to the calls form from other forms" means, but I would pass the field and value:

"ProductionID"; 12345

and use them:

Me(strOpenArgs(0)) = strOpenArgs(1)
 

Users who are viewing this thread

Back
Top Bottom