Passing values between forms

T

Tal

While I am certain that this has been addressed before, I am having serious
trouble parsing out my code.
I have a command button on a form that I am trying to set to open another
form with a value from the first form.
The code for the button is:

Private Sub btnEditFund_Click()
Dim MyArgs As String
MyArgs = [keyFunds] = " & Me.cboSelectFund.Value"
DoCmd.OpenForm "frmEditFunds", , , MyArgs
End Sub

The OnLoad code for the frmEditFunds is:

Private Sub Form_Load()
Dim MyArgs As String

If Not IsNull(Me.OpenArgs) Then
Me.cboFund = Forms!frmAddDonation!cboSelectFund
If IsNull(Me.OpenArgs) Then
DoCmd.GoToRecord , , acNewRec
End If
End Sub

First the form was opening empty but now I am getting the following error
message:

"Block If without End If" and the debugger is opened.

Many many thanks,

Talia
 
A

Arvin Meyer [MVP]

In this code, you are missing an End If

If Not IsNull(Me.OpenArgs) Then
Me.cboFund = Forms!frmAddDonation!cboSelectFund
If IsNull(Me.OpenArgs) Then
DoCmd.GoToRecord , , acNewRec
End If
End Sub

It should look like:

If Not IsNull(Me.OpenArgs) Then
Me.cboFund = Forms!frmAddDonation!cboSelectFund
Else
DoCmd.GoToRecord , , acNewRec
End If

End Sub
 
T

Tal

Thank you Arvin.
You totally solved my problem.
Cheers,
Tal


Arvin Meyer said:
In this code, you are missing an End If

If Not IsNull(Me.OpenArgs) Then
Me.cboFund = Forms!frmAddDonation!cboSelectFund
If IsNull(Me.OpenArgs) Then
DoCmd.GoToRecord , , acNewRec
End If
End Sub

It should look like:

If Not IsNull(Me.OpenArgs) Then
Me.cboFund = Forms!frmAddDonation!cboSelectFund
Else
DoCmd.GoToRecord , , acNewRec
End If

End Sub
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


Tal said:
While I am certain that this has been addressed before, I am having
serious
trouble parsing out my code.
I have a command button on a form that I am trying to set to open another
form with a value from the first form.
The code for the button is:

Private Sub btnEditFund_Click()
Dim MyArgs As String
MyArgs = [keyFunds] = " & Me.cboSelectFund.Value"
DoCmd.OpenForm "frmEditFunds", , , MyArgs
End Sub

The OnLoad code for the frmEditFunds is:

Private Sub Form_Load()
Dim MyArgs As String

If Not IsNull(Me.OpenArgs) Then
Me.cboFund = Forms!frmAddDonation!cboSelectFund
If IsNull(Me.OpenArgs) Then
DoCmd.GoToRecord , , acNewRec
End If
End Sub

First the form was opening empty but now I am getting the following error
message:

"Block If without End If" and the debugger is opened.

Many many thanks,

Talia
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top