Using a defined field in a query

oliver_penney

Board Regular
Joined
Dec 18, 2002
Messages
182
hi

if i have this code:-

Function test88() As DAO.Field
Set test88 = DBEngine.Workspaces(0).Databases(0).TableDefs("tbl_Teleservices_Spider").Fields("BAN Int")
End Function

Sub test77()
MsgBox test88().Name
End Sub

test77 comes up with "BAN Int" hurrah!

BUT i want to define a new field in a query as this field and if i try something like

test99: test88()

in a query field defn, it says "undefined function test88 in expression"

what am i missing?

regards

oliver
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Try making it a Public function.

....

Actually, I just tried that, and it is more than that.
You need to also have test77 return a string.

Try this...

Code:
Public Function test88() As DAO.Field
    Set test88 = DBEngine.Workspaces(0).Databases(0).TableDefs("tbl_Teleservices_Spider").Fields("BAN Int") 
End Function

Public Function test77() As String
    test77 = test88().Name
End Function

Now call Test: test77() in your query.

What are you tring to do with this?
 
Upvote 0

Forum statistics

Threads
1,223,536
Messages
6,172,897
Members
452,488
Latest member
jamesgeorgewalker

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top