How to create a functio with a variable form name

  • Thread starter Thread starter toine
  • Start date Start date
T

toine

I want to make a function to update two fields on a form.
The function has to be used for different forms so I want the formname
to be a variable. How do I do that?
The fields 'gewijzigddoor' en 'gewijzigdop' are equal on all forms and
related tables


The function I made so far (in module1) is:

Function recordgewijzigd(formuliernaam As String)
'hier datum en naam worden hier gesaved
Forms!formuliernaam.gewijzigddoor = inlnaamid
Forms!formuliernaam.gewijzigdop = Date
End Function

I call the function with:
call recordgewijzigd("frmklaarzetten")


when I try the following:
forms! & formuliernaam & .gewijzigddoor=inlnaamid

Access says it's expecting an expression
How do I solve this problem?

Thnx in advance
 
Function recordgewijzigd(formuliernaam As String)
'hier datum en naam worden hier gesaved
Forms(formuliernaam).gewijzigddoor = inlnaamid
Forms(formuliernaam).gewijzigdop = Date
End Function

Note that the form whose name is being passed must be open for the function
to work: you'll get an error if it isn't open.
 
I get indeed an error.
The function is called in the beforeupdate event of the form.
Is that the problem?
 
What's the error you get?

I'll repeat, the form whose name you're passing to the function as
formuliernaam must already be open before you call the function.
 

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

Back
Top