Ambiguous name detected problem

AndyCompanyZ

Registered User.
Local time
Today, 19:58
Joined
Mar 24, 2011
Messages
223
I have a module for a form that produces the above error. I can see why it does but can anyone tell me how to get around this The code is

Private Sub Form_Current()
Me.Form.DurationDays = DateDiff("d", [EventStartDay], [EventEndDate] + 1)
Me.Form.EventDurationHours = DateDiff("h", [EventEndTimeDay1], [EventStartDay1])
End Sub
I can see that it is calling 2 procedures but I need both on the form but if I call them as 2 separate ones it won't work either. Can anyone tell me what to do please. Do I need to make them public functions in which case how do I do that.
Thanks in advance
Andy
 
It sounds like

Private Sub Form_Current()


appears twice in your form module.
 
Thanks. Yes I know that the event happens twice but I need both parts to run on the form and as a bit of a beginner on VBA not sure how to do this.
 
Wht I am saying is the he Sub_Current() appears more than once in your form module. Check and see if it does, if so, delete one that is not needed.
 
What I am trying to do is run both the events in the code
Private Sub Form_Current()
Me.Form.DurationDays = DateDiff("d", [EventStartDay], [EventEndDate] + 1)
Me.Form.EventDurationHours = DateDiff("h", [EventEndTimeDay1], [EventStartDay1])
End Sub

What I mean and I may not be explaining it very well is that I want the text box DurationDays to show the result of EventStartday+ EventEndDate (which works on its own) and the form to show the result in EventDurationHours of the [EventEndTimeDay1], [EventStartDay1] which is a different procedure. So I want both to work on the form at the same time. I'm not sure if this is the right way to do it.
 
Try first to answer David:

Is there a
Private Sub Form_Current ....
End Sub

TWICE in your module code?
 
Ah sorry i see what you mean. No I just have this one on the form.
 
What are DurationDays and EventDurationHours? Are these control names or field names in the record set or both? A more customary way to refer to a control or field in current form would be

Me.ControlName and not Me.Form.WhateverName. I suspect the thing goes sour here.
 
Spikepl
DurationDays and EventDurationHours are field names on a table and are controlnames that are textboxes on the form that will show the results of the datediff calculation.
I have tried taking out the Form part but that gives me a compile error "Method or data member not found"
 
Or you may have run into a "feature" of a Split Form.

If you have two controls in the split forms detail section with the same name in their associated label, then you would get this error.
 
Go to the VBA window, up to DEBUG and click on COMPILE. It should take you to anything that is an error, including the name which is duplicated somewhere. Somewhere you may have a function named DateDiff, where Access already has one, or you have duplicate events in the same module (which is what they were asking about) or you could have a module named the same as one of your forms or functions. Or your VBA project name could be named the same as an Access object. I had someone with a VBA project name of Forms which then caused problems all over the place.

So, various things to look at. If you can't find it, see about uploading a copy of the database (either with no data or bogus data) and we'll see if we can spot it.
 

Users who are viewing this thread

Back
Top Bottom