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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Writing variables to a table

Status
Not open for further replies.

alanjmartin

Technical User
May 17, 2005
13
GB
I am just starting to use VBA in Access and have got myself a bit stuck.
I have a little script, thanks to GVF, which reads a few variables from a table, makes a call to a remote machine, and queries it.
I need to write this info into a table for reference later.
Obviously I have the following variables:
sitename
sitenumber
serialno.
On clearing the test call I would like to write it to a table, along with the date and time

Can any one help
 
Do you mean with a recordset or an update or append query? For example:
Code:
Dim rs As DAO.Recordset
Set rs = CurrentDB.OpenRecordset("tblToUpdate")
'New record
rs.AddNew
rs!SiteName = strSiteName
rs!SiteNumber = strSiteNumber
rs.Update
rs.Close
Set rs = Nothing

Or
Code:
strSQL="Insert Into tblToUpdate ( SiteName, SiteNumber, SerialNo ) Values ( '" & strSiteName & "', " &  intSiteNumber & ", " & intSerialNo
DoCmd.RunSQL strSQL

The above is typed, not tested, so I hope it is right.
 
Thanks for that.
I have added
rs!Date = Date
rs!Time = Time

to add in the Date and time but it tells me that it cannot find the field Date although it can find the others in the same table.......????

Thanks again

Alan
 
Both date and time are reserved words. Try adding square brackets:
rs![Date]
Sometimes it is better to rename the fields.
 
Furthermore, why having two fields for a single DateTime value ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top