Hey all!
I have a dilema: I'm essentially building a tooltip for an object based on data found in a table. I have the following function to query for the data:
It's called like so:
The formatTip function formats the values into a readable tip.
My question is this: Is there a way to have a variable field name in the "Do Until record.EOF" loop? If not, is there a way to query all the data for a particular item then split it so it's readable in the format tips function?
I hope this makes sense.
I have a dilema: I'm essentially building a tooltip for an object based on data found in a table. I have the following function to query for the data:
Code:
Public Function getItemTip(ByRef col As String, ByVal item As String)
Dim query As String
query = "SELECT ITEMS." & col & " FROM ITEMS WHERE (((ITEMS.ITEM_NAME)='" & item & "'))"
Dim MyDB As DAO.Database, record As DAO.Recordset, MyList As String
Set MyDB = CurrentDb
Set record = MyDB.OpenRecordset(query)
Do Until record.EOF ' Loop trough the table
If (Not IsNull(record(col))) Then
MyList = MyList & ";" & record!col
End If
record.MoveNext
Loop
MyList = Mid(MyList, 2)
record.Close
MyDB.Close
getItemTip = MyList
End Function
Code:
Dim item, base, tmp as String
item = "Test Item"
base = getItemTip("ITEM_BASE", item)
complete = getItemTip("ITEM_COMPLETE", item)
...
[I]OBJECTNAME.[/I]ControlTipText = formatTip(base, complete)
Code:
Public Function formatTip(ByVal base As String, ByVal complete As String)
Dim tip As String
' it'd be nice to bold the items in the quotes
tip = "Base: " & base & vbCrLf & "Completion: " & complete
formatTip = tip
End Function
My question is this: Is there a way to have a variable field name in the "Do Until record.EOF" loop? If not, is there a way to query all the data for a particular item then split it so it's readable in the format tips function?
I hope this makes sense.
Last edited: