Annoying Error

music_al

Registered User.
Local time
Today, 20:47
Joined
Nov 23, 2007
Messages
200
Hi

I have all of a sudden and for no apparent or obvious reason, begun to get an annoying error in my database. Can anyone help ?

Access Error.PNG
 
What is the code in your on change event that is driving this?
 
Hi Alan,

Its happening when I change two Combo Boxes...

Private Sub cbo_Postcode1_Change()
txt_Town_City.Value = cbo_Postcode1.Column(2)
txt_County.Value = cbo_Postcode1.Column(3)
End Sub


Private Sub cbo_Title_Change()
txt_Gender.Value = cbo_Title.Column(2)

End Sub
 
Hi Alan

Thanks for this. I dont get an error number, just the message that I put in the attachment.


Al
 
Sorry, I don't have an answer. Hopefully, someone else who has seen this will jump in.
 
Hi Spike

I can find the Tools Menu in the VBA Window but I dont see an option for Compile.

Allan
 
Hi Spike

I can find the Tools Menu in the VBA Window but I dont see an option for Compile.

Allan

It's actually under DEBUG > COMPILE

but first off, why are you using the On Change event to begin with? That can cause cyclic problems depending on what you are doing and if you have anything in the Before Update event as well.
 
Oh, and the corrected code would be:
Code:
Private Sub cbo_Postcode1_[B][COLOR=red]AfterUpdate[/COLOR][/B]()
   [B][COLOR=red]Me.[/COLOR][/B]txt_Town_City = [B][COLOR=red]Me.[/COLOR][/B]cbo_Postcode1.Column(2)
   [B][COLOR=red]Me.[/COLOR][/B]txt_County = [B][COLOR=red]Me.[/COLOR][/B]cbo_Postcode1.Column(3)
End Sub


Private Sub cbo_Title_[B][COLOR=red]AfterUpdate[/COLOR][/B]()
   [B][COLOR=red]Me.[/COLOR][/B]txt_Gender = [B][COLOR=red]Me.[/COLOR][/B]cbo_Title.Column(2)
End Sub

And you should be using ME along with the control names as that can avoid certain issues around ambiguity. Also, make sure that your combo's have the column counts set properly and you do realize that Column(2) is the THIRD column, correct?
 
Thanks Bob

I get an error when I run the Compile (see attachment).

I have used the On Change as this seems like the most obvious as I want the contents of a text box to change when I change the content of a combo box. Im not using the before update function.

Would you recommend an other way of doing it ?

Regards

AlCompile Error.JPG
 
Thanks Bob

I get an error when I run the Compile (see attachment).

I have used the On Change as this seems like the most obvious as I want the contents of a text box to change when I change the content of a combo box.
It may seem obvious but it isn't correct to use like that. It will fire on every keystroke, etc. Use the AFTER UPDATE event of the combo. It is RARE that you would need to use the ON CHANGE event for anything.


Also, it sounds, from your error that you have manually typed in an event header when one already exists. Make sure you don't have any of the same events in the module.
 
Hi

I think I figured it out.

I had a field (called Full_Name) linked to a Control on a form which also had a Sub called Full_Name.

I THINK that was the problem but Ive also learnt some good practices from this.

Thanks guys

Al
 

Users who are viewing this thread

Back
Top Bottom