Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set Variable equal to table field 1

Status
Not open for further replies.

bgreen

Programmer
Feb 20, 2003
185
CA
Hi,

I want to assign a variable to a value retaine in a table. I am unsure how to do this.

sUID = "SELECT tblTransferInfo.User FROM tblTransferInfo;"

MsgBox "UID: " & sUID

I want the value for the Field User to display.
 
How about the opposite?

I'd like to set a field in the table that is the recordsource of the form i'm using so that

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

will save the field set in the vba code as well.

I've used the DAO.Database,RecordSet,and Field objects with .AddNew and .Update but I'm hoping I can do this in one line since the field is in the form's recordset table.

Thanks,

David
 
Figured it out- put the field name in brackets.

If I want to set the field Username to the variable sUsername I can do so as follows:

Dim sUsername As String
sUsername = Environ("username") 'retrievs login name
[Username] = sUsername 'example of setting field to a variable

David
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top