Getting value from a table in VB

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have a value (myvalue) stored in a table (mytable), in the column mycolumn,

that I want to assign to a string (mystring) in VB. What's the syntax to do

this?

of course, mystring = mytable.mycolumn doesn't seem to work

Thanks for the help.
 
Good morning, Audrey. Here's the thing. Are you looking for a single field for a single record? If so, you need to somehow suggest to the code your criteria for selection. For example, if I wanted to look up my name, but all I have is my userID, it might look like this:

mystring = dlookup("[myname]","UserLists","UserID = dwittma")

Since may result in several records being returned, let's actually change the functio name from dlookup to dlast or dfirst (assuming nobody else has my UserID <g>)

mystring = dlast("[myname]","UserLists","UserID = dwittma")

If you run the code and then use ?mystring in the Immediate Window in the VBA editor, you should see "Derek Wittman" (or your result) on the next line. I hope this helps you out!

Derek
 
Back
Top