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

Reference variable Form Name in Module Function Recordset 1

Status
Not open for further replies.

Binnit

Technical User
Apr 28, 2004
627
US
I would like to pass the form name to a procedure within a module so that it can be used within a recordset update, I have tried various methods and got various error messages in return!, my current bit of code looks like this

(FN is the name of the form being passed in to the function)
Code:
Public Sub Addrec(FN)


    Set dbs = CurrentDb
    Set rst = dbs.OpenRecordset("tbltest", dbOpenDynaset)

    With rst
        .AddNew
        ![f2] = Forms![FN]![txtF2]
        ![f3] = Forms![FN]![txtF3]
        ![f4] = Forms![FN]![txtF4]
        .Update
    End With
    
End Sub

Can this be done?

If IT ain’t working Binnit and Reboot
 
Try this:
![f2] = Forms(FN)![txtF2]

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PHV
Once again you have come up trumps... excellent and many thanks.

If IT ain’t working Binnit and Reboot
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top