entering a form name as a function's value in a textbox's devault value.

M

Mark Kubicki

=PrintOrder([me])

I have entered, as the default value for a text box on a subform, the UDF
function PrintOrder() (see below);
unfortunately, it yields result: #Name?

when I check the default value entry, it displays as (and reverts to)
=PrintOrder([me]); which I suspect is causing the problem. Access may be
looking for a field on the subform named [Me] -which does not exist. I mean
for "Me" to return the name of the subform (or more directly, the name of
the parent form-but that would be a different question). When I delete the
[]'s, they return. I suspect my approach may be flawed, and that "Me"
cannot be used in this manner (?)

Does anyone have any suggestions on where I ought to be looking for the
error?

as always, thanks in advance,
-mark



Public Function PrintOrder(frm As Access.Form)
vStr = "[Type] = '" & frm.Parent.Type & "'"
varx = DLookup("[Type]", "tblInstallationNotes", vStr)
vLen = Len(Nz(varx))
If vLen > 0 Then
PrintOrder = DMax("[PrintOrder]", "tblInstallationNotes") + 1
Else
PrintOrder = 1
End If
End Function
 
K

Klatuu

Brackets arround the Me is incorrect.
If you want to return the name of the form, the correct syntax would be
Me.Name

To return the form as an object reference, you would need to dim the
argument in your function as a form object:

For example:

PrintOder(frm As Form)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top