Perplexed n VBA Access

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have the following routine in a form and am having a problem I can not find
the answer to. When th following is run:

Private Sub Form_AfterUpdate()
Forms!frmYardSales2![frmCountSale subform].Requery
End Sub

I keep getting this error:
Run-time error '2645'
Microsoft Access can't find the field 'frmCountSale subform' referred in
your expression.

I have doubled, tripled, quadrupled, etc. checked the name and it's correct.
What's more perplexing is I copied this from another version of the same
program and it works fine in that database. I have gone through properties
for all the fields, all the forms, all the subforms, and they are seemingly
identical to the other access database program that works right. This one
refuses to work. I'm new to VBA and I'm not sure where else to look or really
what else to look for. If anyone has any ideas and could possibly point me in
a direction of discovery, I would greatly appreciate the assistance.

Thank you,
Randy M.
 
Two things ---
1. frmCountSale subform needs to be the name of the subform control and not
the name of the subform it contains
2. You need to requery the form inside the subform control not the subform
control. Change your code to:
Forms!frmYardSales2![frmCountSale subform].Form.Requery
 
Thanks for responding so quickly. I hate to seem totally stupid, but as I
said I'm new to Access and VBA especially. Where do I go to change the name
of the subform control. I haven't seen it in any of the property sheets I've
looked at? What this does is there's a query that counts the number of sales
in the current year and displays it in a subform. The actual data is entered
thru another sub-form that calls this query to display the info. I hope
that's understandable. What I really can't understand is why it works
perfectly the way it is in one database and won't work in another one that's
a copy of the one it works in. I really do appreciate your help and I hope
that I'm not being too inquisitive about all this. I was a programmer for
years in Cobol, but that was quite a few years ago. And, while I understand
the basic concept for Access and even VB, I'm just not adept at the syntax
yet to know how to do what I want and to fix 'bugs' that pop up. Once again,
thanks PC Datasheet for your answer.

Randy M

PC Datasheet said:
Two things ---
1. frmCountSale subform needs to be the name of the subform control and not
the name of the subform it contains
2. You need to requery the form inside the subform control not the subform
control. Change your code to:
Forms!frmYardSales2![frmCountSale subform].Form.Requery

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
Over 1100 users have come to me from the newsgroups requesting help
(e-mail address removed)





WCDoan said:
I have the following routine in a form and am having a problem I can not
find
the answer to. When th following is run:

Private Sub Form_AfterUpdate()
Forms!frmYardSales2![frmCountSale subform].Requery
End Sub

I keep getting this error:
Run-time error '2645'
Microsoft Access can't find the field 'frmCountSale subform' referred in
your expression.

I have doubled, tripled, quadrupled, etc. checked the name and it's
correct.
What's more perplexing is I copied this from another version of the same
program and it works fine in that database. I have gone through properties
for all the fields, all the forms, all the subforms, and they are
seemingly
identical to the other access database program that works right. This one
refuses to work. I'm new to VBA and I'm not sure where else to look or
really
what else to look for. If anyone has any ideas and could possibly point me
in
a direction of discovery, I would greatly appreciate the assistance.

Thank you,
Randy M.
 
The subform 'box', that exists on your primary form, is the subform control.
If you click the box once, you get the properties for the control. Click the
box a second time, and the properties become that of the subform, itself.
Also, for the subform control, the title bar - of the properties box - will
say "Subform/Subreport: <name of control>".

So, click somewhere else on your form, then click the subform box once.
Then choose the Other tab, and check the Name property.

Then follow the previous recommendations.



WCDoan said:
Thanks for responding so quickly. I hate to seem totally stupid, but as I
said I'm new to Access and VBA especially. Where do I go to change the name
of the subform control. I haven't seen it in any of the property sheets I've
looked at? What this does is there's a query that counts the number of sales
in the current year and displays it in a subform. The actual data is entered
thru another sub-form that calls this query to display the info. I hope
that's understandable. What I really can't understand is why it works
perfectly the way it is in one database and won't work in another one that's
a copy of the one it works in. I really do appreciate your help and I hope
that I'm not being too inquisitive about all this. I was a programmer for
years in Cobol, but that was quite a few years ago. And, while I understand
the basic concept for Access and even VB, I'm just not adept at the syntax
yet to know how to do what I want and to fix 'bugs' that pop up. Once again,
thanks PC Datasheet for your answer.

Randy M

PC Datasheet said:
Two things ---
1. frmCountSale subform needs to be the name of the subform control and not
the name of the subform it contains
2. You need to requery the form inside the subform control not the subform
control. Change your code to:
Forms!frmYardSales2![frmCountSale subform].Form.Requery

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
Over 1100 users have come to me from the newsgroups requesting help
(e-mail address removed)





WCDoan said:
I have the following routine in a form and am having a problem I can not
find
the answer to. When th following is run:

Private Sub Form_AfterUpdate()
Forms!frmYardSales2![frmCountSale subform].Requery
End Sub

I keep getting this error:
Run-time error '2645'
Microsoft Access can't find the field 'frmCountSale subform' referred in
your expression.

I have doubled, tripled, quadrupled, etc. checked the name and it's
correct.
What's more perplexing is I copied this from another version of the same
program and it works fine in that database. I have gone through properties
for all the fields, all the forms, all the subforms, and they are
seemingly
identical to the other access database program that works right. This one
refuses to work. I'm new to VBA and I'm not sure where else to look or
really
what else to look for. If anyone has any ideas and could possibly point me
in
a direction of discovery, I would greatly appreciate the assistance.

Thank you,
Randy M.
 
Sharkbyte,
That did it! After I changed the name of the subform control it worked
fine the way it was. That's all it took. Many thanks to you and to PC
Datasheet for the excellent help. Man, does that take a load off my brain.
Thanks Again,
Randy M
 
To the original poster:

Most people here have a common belief that the newsgroups are for *free
exchange of information*.
But Steve is a notorious job hunter in these groups, always trying to sell
his services.


Before you intend to do business with him look at:
http://home.tiscali.nl/arracom/whoissteve.html (updated)



PC Datasheet said:
Two things ---
1. frmCountSale subform needs to be the name of the subform control and not
the name of the subform it contains
2. You need to requery the form inside the subform control not the subform
control. Change your code to:
Forms!frmYardSales2![frmCountSale subform].Form.Requery

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
Over 1100 users have come to me from the newsgroups requesting help
(e-mail address removed)





WCDoan said:
I have the following routine in a form and am having a problem I can not
find
the answer to. When th following is run:

Private Sub Form_AfterUpdate()
Forms!frmYardSales2![frmCountSale subform].Requery
End Sub

I keep getting this error:
Run-time error '2645'
Microsoft Access can't find the field 'frmCountSale subform' referred in
your expression.

I have doubled, tripled, quadrupled, etc. checked the name and it's
correct.
What's more perplexing is I copied this from another version of the same
program and it works fine in that database. I have gone through properties
for all the fields, all the forms, all the subforms, and they are
seemingly
identical to the other access database program that works right. This one
refuses to work. I'm new to VBA and I'm not sure where else to look or
really
what else to look for. If anyone has any ideas and could possibly point me
in
a direction of discovery, I would greatly appreciate the assistance.

Thank you,
Randy M.
 

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

Back
Top