Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with an error

Status
Not open for further replies.

tpowers

Technical User
Nov 2, 2002
153
US
I have four radio buttons that I have set an after update event. This after update looks at what value the set of radio buttons ends up with. I do an if state that states
if frameSelections = 1 then
txtbox.text = "sjfksjflksjdf"
else:
if frameSelections = 2 then
txtbox.text = "asjfsjlflksdjflksj"
else:
if frameSelections = 3 then
txtbox.text = "uworuwoeiruwoeur"
end if
end if
end if

Now what is happening is that the code is working and it is update the txtbox that I want it to but then I get this error:

The macro or function set to the beforeUpdate or ValidationRule property for this field is preventing Microsoft Access from saving the data in the field.

Now what I do not understand is that I do not have any beforeUpdate for ValidationRule for any field on my form.

Can some one please help me out with this error.


the error number is:

2115

Thank you in advance,

TPowers

P.S.

I am using MS Access 2002 (XP)


 
I see a couple of things wrong with your code. First off, you have a colon following your "Elses". Going back to the early days of Basic (MS Visual Basic and hence Access' VBA are based on MS QuickBasic 4.5) anything followed by a colon was considered a sub-function. I'm guessing this is why you're getting the cryptic error message about a "macro or function set to the beforeUpdate or ValidationRule property ...". Also with the If...ElseIf structure you only need one End If. Your code should read:

If frameSelections = 1 Then
txtbox.text = "sjfksjflksjdf"
ElseIf frameSelections = 2 Then
txtbox.text = "asjfsjlflksdjflksj"
ElseIf frameSelections = 3 Then
txtbox.text = "uworuwoeiruwoeur"
End If

I haven't had occassion to use radio buttons, but I'm assuming that the syntax you're using (i.e. "frameSelections = 1") is correct.

Hope this helps.

The Missinglinq
"It's got to be the going,
not the getting there that's good!"
-Harry Chapin
 
Ok I like the structure that you gave, it made everything easier to read, however this is not working. I thought maybe the "frameSelection" was the issue so is is how I coded it, and it still did not work.

do you know why?

P.S. I am getting the same error.

Thanks in advance,

TPowers



If Me.txtDecisionCode.Value = 1 Then
txtDECISION.SetFocus
txtDECISION.Locked = False
txtDECISION.Text = "Hearing Liable"
txtDECISION.Locked = True
ElseIf Me.txtDecisionCode.Value = 2 Then
txtDECISION.SetFocus
txtDECISION.Locked = False
txtDECISION.Text = "Hearing Not Liable"
txtDECISION.Locked = True
ElseIf Me.txtDecisionCode.Value = 3 Then
txtDECISION.SetFocus
txtDECISION.Locked = False
txtDECISION.Text = "Failure To Appear"
txtDECISION.Locked = True
ElseIf Me.txtDecisionCode.Value = 4 Then
txtDECISION.SetFocus
txtDECISION.Locked = False
txtDECISION.Text = "Rescheduled"
txtDECISION.Locked = True
End If
 
Like I said, I've never had the occasion to use radio buttons; this may be where your problem lies. However, your control is named "Me.txtDecisionCode" which would indicate that it is a text box. This being so, its value cannot be "= 1" or "= 2", etc. If it is in fact a text box (as its name suggests) then the statement must be:

If Me.txtDecisionCode.Value = "1" Then
or
If Me.txtDecisionCode.Value = "2" Then

etc.

with the emphasis on the double quotation marks around the 1 or 2, etc. Text should always be referenced within double quotation marks. A statement such as

Me.txtDecisionCode = 1

is only valid if "txtDecisionCode" is numeric. Try this and get back to me if this doesn't correct your problem.

The Missinglinq



"It's got to be the going,
not the getting there that's good!"
-Harry Chapin
 
Ok here we go again.

The following code is giving me the same error IE: 2115

As stated in my above and first theard I do not have any beforeUpdate or validation rules set to the field that I want to add data to nore is this field connected to a table or query. can someone please tell me why this error is comming up.


Thank you in advance

Tpowers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top