Function

User avatar
burrina
4StarLounger
Posts: 550
Joined: 30 Jul 2014, 23:58

Function

Post by burrina »

My question is: If you have a form function, can you call that from a query? Or get those results into a query?

User avatar
HansV
Administrator
Posts: 78370
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Function

Post by HansV »

In general, if you want to call a function in a query, that function should be in a standard module, not in a form module.

There are ways to get around this, but I don't recommend that.
Best wishes,
Hans

User avatar
burrina
4StarLounger
Posts: 550
Joined: 30 Jul 2014, 23:58

Re: Function

Post by burrina »

The function is from the form. It is called via cmd btn and then populates the form. I was curious if I could get those results into a qry and if so how?

User avatar
HansV
Administrator
Posts: 78370
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Function

Post by HansV »

That doesn't make sense to me. Just create a query to return the results you want.
Best wishes,
Hans

User avatar
burrina
4StarLounger
Posts: 550
Joined: 30 Jul 2014, 23:58

Re: Function

Post by burrina »

No, the function is quite complex and of course can be called from anywhere.
Set rsjob = db.OpenRecordset(strjob, dbOpenDynaset)

Set rsemp = dbOpenRecordsetb(strEmp, dbOpenDynaset)

tblJobs tblEmployees

User avatar
HansV
Administrator
Posts: 78370
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Function

Post by HansV »

You cannot just "get those results into a qry". Access doesn't work that way.
You might use the code to create or populate a temporary table, and then use that table for whatever you want to do.
Best wishes,
Hans

User avatar
burrina
4StarLounger
Posts: 550
Joined: 30 Jul 2014, 23:58

Re: Function

Post by burrina »

Ok. That's what I needed to know. Thank You.