Reserved Error 2950

gowans07

Registered User.
Local time
Today, 12:45
Joined
Sep 27, 2011
Messages
36
Just created a report and had the following code:
Code:
Private Sub Report_Activate()
TxtPurchaseOrder.Visible = True
TxtPurchaseOrder.SetFocus
Label17.Caption = "Thank you for your purchase order " & TxtPurchaseOrder.Text & " received "
TxtDate.Visible = True
TxtDate.SetFocus
TxtPurchaseOrder.Visible = False
Label17.Caption = Label17.Caption & TxtDate.Text & "."
Text28.SetFocus
TxtDate.Visible = False
End Sub
Worked perfectly now i've introduced a subreport and it errors out on the second line, TxtPurchaseOrder.SetFocus giving the error stated earlier. TxtPurchaseOrder is a bound field linking to a table, the subreport is bound to a query.

Thanks

TG
 
If you have a text box control on your form names TxtDate that may mean you have a field in your table/query named Date ?? If so, you have used a reserved word and this should be sorted.

Do you have a control named Text28 ?
If so, try
Code:
Me.Text28.SetFocus
 
Hmm, i've changed TxtDates to something different, still getting the same error on TxtPurchaseOrder.setfocus
 
I use
Code:
Me.controlname.visible = True/False
Me.controlname.setfocus

A control name can be TxtDate but if your Data Source is Date, then you have an issue ie it is not your Form that would be an issue but the Table and or Query the form is using - bound to or just the control using.

When you type your code (control property) do you get the auto prompt from vba ?
 
Yeh autoprompt pops up everything, double and triple checked the referenced names are correct but to no avail preventing the error. added me. to the affected controls to. TxtPO is bound to the PO field, could this cause a problem? Done some google searches, most people seem to get this error on .SetFocus as of yet cant find a solution
 
You will get SetFocus issues when the control you want to move to has had some activity - I didn't follow this too much myself but mostly put focus to a Refresh button or some other neutral place.
 
hmm okay, is it possible to put focus onto the main report not the subreport on report_activate?
 
Why is it important where the focus is on a report ?
With a Form, you can set focus to a main form so I guess a report would be similar.
 
i'm trying to string together the contents of 2 bound controls into a label with some other text inside. Bad coding i know but cant think of any other way, fairly new to access.
 
okay finally solved it, changed my code to this:

Private Sub Report_Load()
Label17.Caption = "Thank you for your purchase order " & Me.PO.Value & " received "
Label17.Caption = Label17.Caption & Me.Date_Received.Value & "."
End Sub

directly referenced the bound fields.
 
Glad you resolved your issue but I can not see any connection between your original post and final solution :confused:
 
Like i said i'm new, was trying to reference text boxes directly by setting focus to them then retrieving there .text

This then caused the 2950 Error

now using Me.ControlName.Value instead, whats the difference between .value and .text for text boxes?
 
If you wanted to use the data from a Control then that would have been the question to ask.
As you discovered, you don't need to Focus on a control to use the value of it.
This means you can get a value from any open form.

There is no such thing as .text

Me.textFirstname is refering to the data held in the control named textFirstName on the Main Form.

Me.SantaClause is refering to a control named SantaClause

Me.ControlName.Value is refering to a control on your Main form and the property - Value.

Me.ControlName (name of your control) is the start of code to do a lot of things to your form controls.
 
Fantastic explanation thank you! Slowly learning how different VBA is from VB6, simple things like that make a huge difference. Thanks again
 

Users who are viewing this thread

Back
Top Bottom