G
Guest
I am creating a new function and need to pass the name of a field as a
parameter. I am passing a query name and it works fine. But then I need to
use the field, also a parameter but can't figure out how to convert the name
so it can be used and not look like a string. Below is my before creating
the new function code (that works) and then my attempt and creating a
function out of it.
Thanks for the help,
Dave
RS defined as a global variable / Dim db As Database, RS As Recordset
Original code
Set RS = db.OpenRecordset("TreeLevel1", dbOpenDynaset, dbReadOnly)
Do Until RS.EOF
strNode1Text = StrConv("Level1" & RS![ProcessID], vbLowerCase)
strVisibleText = RS![PID]
Set nodCurrent = objTree.Nodes.Add("Level0CV", tvwChild)
nodCurrent.Text = strVisibleText ' Text.
nodCurrent.Key = strNode1Text ' Unique ID."
nodCurrent.Image = PBitmap
nodCurrent.Tag = RS![ProcessID]
RS.MoveNext
Loop
RS.Close
New function (needs help)
Private Function AdddbNode(QryName As String, LevelText As String,
UniqueIDText As String, VisibleText As String, NodeName As String, NBitmap As
Integer, NodeTag As String) As Boolean
Set RS = db.OpenRecordset(QryName, dbOpenDynaset, dbReadOnly)
Do Until RS.EOF
strNode1Text = StrConv(LevelText & RS!UniqueIDText, vbLowerCase)
strVisibleText = RS!VisibleText
Set nodCurrent = objTree.Nodes.Add(NodeName, tvwChild)
nodCurrent.Text = strVisibleText ' Text.
nodCurrent.Key = strNode1Text ' Unique ID."
nodCurrent.Image = NBitmap
nodCurrent.Tag = RS!NodeTag
RS.MoveNext
Loop
RS.Close
AdddbNode = True
End Function
parameter. I am passing a query name and it works fine. But then I need to
use the field, also a parameter but can't figure out how to convert the name
so it can be used and not look like a string. Below is my before creating
the new function code (that works) and then my attempt and creating a
function out of it.
Thanks for the help,
Dave
RS defined as a global variable / Dim db As Database, RS As Recordset
Original code
Set RS = db.OpenRecordset("TreeLevel1", dbOpenDynaset, dbReadOnly)
Do Until RS.EOF
strNode1Text = StrConv("Level1" & RS![ProcessID], vbLowerCase)
strVisibleText = RS![PID]
Set nodCurrent = objTree.Nodes.Add("Level0CV", tvwChild)
nodCurrent.Text = strVisibleText ' Text.
nodCurrent.Key = strNode1Text ' Unique ID."
nodCurrent.Image = PBitmap
nodCurrent.Tag = RS![ProcessID]
RS.MoveNext
Loop
RS.Close
New function (needs help)
Private Function AdddbNode(QryName As String, LevelText As String,
UniqueIDText As String, VisibleText As String, NodeName As String, NBitmap As
Integer, NodeTag As String) As Boolean
Set RS = db.OpenRecordset(QryName, dbOpenDynaset, dbReadOnly)
Do Until RS.EOF
strNode1Text = StrConv(LevelText & RS!UniqueIDText, vbLowerCase)
strVisibleText = RS!VisibleText
Set nodCurrent = objTree.Nodes.Add(NodeName, tvwChild)
nodCurrent.Text = strVisibleText ' Text.
nodCurrent.Key = strNode1Text ' Unique ID."
nodCurrent.Image = NBitmap
nodCurrent.Tag = RS!NodeTag
RS.MoveNext
Loop
RS.Close
AdddbNode = True
End Function