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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form name as a variable in a function - HELP!!! 1

Status
Not open for further replies.

scoobey

Technical User
Sep 18, 2001
32
GB
Hi there!

I think I have quite a simple problem here. Basically, i'm trying to return the value of a specific field using the forms!<form name>!<field> object. I have a few forms that have the same fields and I wanted to create a module to validate what is in the field, but I can't seem to get the form name variable to work. The function is called using 'call CheckRecords(form.name)'

A scaled down version of the function looks like this:

public function CheckRecords(frmName)
msgbox forms!(frmName)!CmdID.value
End Function

I just can't seem to pass the form name through to the forms!... part without it generating an error or taking it literally. I've tried:

forms![frmName]!CmdID.value
forms!& frmName &!CmdID.value

..and variations thereof.

Please help!!!!!!!!!???????
 
So close

[tt]public function CheckRecords(byval frmName as string) as <somedatatype>
msgbox forms(frmName).controls("CmdID").value
...
' though
msgbox forms(frmName)!CmdID.value
' should also work[/tt]

Roy-Vidar
 
I new it was something simple - how annoying!
Thanks very much for your help!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top