easy one i think

D.Mair

David
Local time
Today, 05:33
Joined
Jun 1, 2001
Messages
33
I am getting an error, :confused:
I have not worked with access for a while and it is more likely that it is something simple

it is error 2544

You entered an expression that has an invalid reference to the property form/report
The property may not exist or may not apply to the object you specified


it highlights "strPath = Me![SubFrmPaths].Form![PathArch]".


Dim strPath As String

If Me![Archived] = -1 Then

strPath = Me![SubFrmPaths].Form![PathArch]
Else
strPath = Me![SubFrmPaths].Form![PathCorr]
End If

if you need more info please ask

Thanks David
 
Last edited:
Try

strPath = Forms!MainFormName!SubFrmPaths.PathArch

presuming PathArch is a field on a subform.

Dave
 
nope that didn't work. :(
I wonder if the subfrom isn't loaded when the code asks for the info.
Could that be what is wrong.
if so how do i stop it happening.
thanks david
 
have looked into this more with a clearer head and have found that i don't get any of the subform information pulled through the code.

Any ideas what might be happening

this dosn't pull the year in

Dim Year as String

Year = Nz(Me![SubFrmQryJobYear subform].Form![Year])

I think this did work 6 months ago.

Thanks David
 
D.Mair said:
this dosn't pull the year in

Dim Year as String

You can't go calling a string variable year - it's a reserved word in Access. The interpreter will get Year (the string) mixed up with Year (the function). If you want it as a string (although I don't see why an Integer isn't the best option) then prefix it with str. i.e. strYear

That way, when looking at the code you can immeditely tell what type of variable or object something is.

P.S. Are you Killie or A*r United? :rolleyes:
 
would say Killie but not a football fan really I will try that and see if it works

Thanks david
 
well what happens is that the strYear comes from a query that take a Job Number like
2004001 and
takes off the 001 making
strYear 2004

then i use the 2004 to create the file path C:\file\2004\file\file

Dim strYear As String
strYear = Nz(Me![SubFrmQryJobYear].Form![strYear])

when it trys to run this it comes up with error 2455 as before.

Thanks David
 
D.Mair said:
strYear = Nz(Me![SubFrmQryJobYear].Form![strYear])

You can't refer to a variable on a form - only controls.
 

Users who are viewing this thread

Back
Top Bottom