Access

G

Guest

I have and Access application, one of the forms uses two tables (donors,
donations) they are connected by 'donor-id'.
I am getting a Compile Error (Qualifier must be collection). The code
follows:

Private Sub Donors_Click()
On Error GoTo Err_Donors_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Donor Donations"

stLinkCriteria = "[donor-id]=" & Me![donor-id]
*** donations![donor-id] = doners![donor-id]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Donors_Click:
Exit Sub

Err_Donors_Click:
MsgBox Err.Description
Resume Exit_Donors_Click

End Sub

The statement that causes the error is marked ***. What am I doing wrong?
Please help.
 
S

StrayBullet via AccessMonster.com

Basically, it has no idea what to do with donations![donor-id] = doners!
[donor-id]. As written, it appears to be query criteria. Is donations![donor-
id] = doners![donor-id] actually part of the form's underlying query? If so,
there really shouldnt be a need for it to be included in the vba.

I have and Access application, one of the forms uses two tables (donors,
donations) they are connected by 'donor-id'.
I am getting a Compile Error (Qualifier must be collection). The code
follows:

Private Sub Donors_Click()
On Error GoTo Err_Donors_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Donor Donations"

stLinkCriteria = "[donor-id]=" & Me![donor-id]
*** donations![donor-id] = doners![donor-id]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Donors_Click:
Exit Sub

Err_Donors_Click:
MsgBox Err.Description
Resume Exit_Donors_Click

End Sub

The statement that causes the error is marked ***. What am I doing wrong?
Please help.
 
G

Guest

What I am trying to do is 'donors![donors-id]' has the the id of the donor.
When I call the next form I would like to pass that id to the new form. Can
you tell me the best way to do that? I am a little lost in this area and
cannot find in in the doc. Thanks again.
--
Norm Bohana


StrayBullet via AccessMonster.com said:
Basically, it has no idea what to do with donations![donor-id] = doners!
[donor-id]. As written, it appears to be query criteria. Is donations![donor-
id] = doners![donor-id] actually part of the form's underlying query? If so,
there really shouldnt be a need for it to be included in the vba.

I have and Access application, one of the forms uses two tables (donors,
donations) they are connected by 'donor-id'.
I am getting a Compile Error (Qualifier must be collection). The code
follows:

Private Sub Donors_Click()
On Error GoTo Err_Donors_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Donor Donations"

stLinkCriteria = "[donor-id]=" & Me![donor-id]
*** donations![donor-id] = doners![donor-id]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Donors_Click:
Exit Sub

Err_Donors_Click:
MsgBox Err.Description
Resume Exit_Donors_Click

End Sub

The statement that causes the error is marked ***. What am I doing wrong?
Please help.
 
S

StrayBullet via AccessMonster.com

First, remove the "line donations![donor-id] = doners![donor-id]"
On the form DonorDonations, you can set the field which needs to be filled
with the donor-id. Something along the lines of the following in the form's
On_Open event:

Me.[donor-id] = Forms!NameOfCallingForm.[donor-id]
What I am trying to do is 'donors![donors-id]' has the the id of the donor.
When I call the next form I would like to pass that id to the new form. Can
you tell me the best way to do that? I am a little lost in this area and
cannot find in in the doc. Thanks again.
Basically, it has no idea what to do with donations![donor-id] = doners!
[donor-id]. As written, it appears to be query criteria. Is donations![donor-
[quoted text clipped - 29 lines]
 
G

Guest

Hi again, I removed the code and put the following code in the OnForm Open:

Private Sub Form_Open(Cancel As Integer)
[donor-id] = Forms!Donors.[donor-id]
End Sub

I am now getting a RunTime error 2448. Can you help me again I cannot find
out what the error means. I used your suggested statement it gave me and
error so I changed to this.
--
Norm Bohana


StrayBullet via AccessMonster.com said:
First, remove the "line donations![donor-id] = doners![donor-id]"
On the form DonorDonations, you can set the field which needs to be filled
with the donor-id. Something along the lines of the following in the form's
On_Open event:

Me.[donor-id] = Forms!NameOfCallingForm.[donor-id]
What I am trying to do is 'donors![donors-id]' has the the id of the donor.
When I call the next form I would like to pass that id to the new form. Can
you tell me the best way to do that? I am a little lost in this area and
cannot find in in the doc. Thanks again.
Basically, it has no idea what to do with donations![donor-id] = doners!
[donor-id]. As written, it appears to be query criteria. Is donations![donor-
[quoted text clipped - 29 lines]
The statement that causes the error is marked ***. What am I doing wrong?
Please help.
 
S

StrayBullet via AccessMonster.com

If Me![donor-id] = Forms!NameOfCallingForm.[donor-id] doesn't work, check to
be sure that the name of the control on the form which you are attempting to
write to is actually named donor-id. If not, you would need to use that name
or rename it before using donor-id in the vba.
ex: Me!text123 = Forms!Donors.[donor-id]

Another option is to use the On_Load rather than On_Open event. Some people
use the On_Current event.

Hi again, I removed the code and put the following code in the OnForm Open:

Private Sub Form_Open(Cancel As Integer)
[donor-id] = Forms!Donors.[donor-id]
End Sub

I am now getting a RunTime error 2448. Can you help me again I cannot find
out what the error means. I used your suggested statement it gave me and
error so I changed to this.
First, remove the "line donations![donor-id] = doners![donor-id]"
On the form DonorDonations, you can set the field which needs to be filled
[quoted text clipped - 12 lines]
 
M

missinglinq via AccessMonster.com

Going back to your original code, I suspect that

line donations![donor-id] = doners![donor-id]

was supposed to be

line donations![donor-id] = donors![donor-id]

You spelled "donor" as "doner," with an "i" instead of an "o".
 
G

Guest

Thank you OnLoad worked.
--
Norm Bohana


StrayBullet via AccessMonster.com said:
If Me![donor-id] = Forms!NameOfCallingForm.[donor-id] doesn't work, check to
be sure that the name of the control on the form which you are attempting to
write to is actually named donor-id. If not, you would need to use that name
or rename it before using donor-id in the vba.
ex: Me!text123 = Forms!Donors.[donor-id]

Another option is to use the On_Load rather than On_Open event. Some people
use the On_Current event.

Hi again, I removed the code and put the following code in the OnForm Open:

Private Sub Form_Open(Cancel As Integer)
[donor-id] = Forms!Donors.[donor-id]
End Sub

I am now getting a RunTime error 2448. Can you help me again I cannot find
out what the error means. I used your suggested statement it gave me and
error so I changed to this.
First, remove the "line donations![donor-id] = doners![donor-id]"
On the form DonorDonations, you can set the field which needs to be filled
[quoted text clipped - 12 lines]
The statement that causes the error is marked ***. What am I doing wrong?
Please help.
 

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