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

VB & MS Access

Status
Not open for further replies.

cgagnon

Technical User
Oct 12, 2001
14
CA
Hi!
Can anyone point me to some info on how to read/add/update records in an Access table using VB. I am new at both Access & VB. I have an Access table (TableA) that has date/time fields in it. I have another table (TableB) that has basically the same info, except that it has number fields instead of date fields (i.e. it contains yyyymmdd data as 20011231). I would like to create a VB program that will read the records in TableB, convert the numeric (date) field to a proper date field, and then add the record to Table A.
Thank you for your help.
 
What background are you coming from? I will give you some code to get started. You can open more than 1 table and loop through them to find waht you are looking for with an sql statment. The second example opens the table with a sql statment. Make sure you have MS DOA 3.1 ... selected in the refence library. Good Luck!!

Function GetTables()
Dim rsttmp As DAO.Recordset
Dim rstDav As DAO.Recordset
Dim sTest As String

Set rsttmp = CurrentDb.OpenRecordset("results")

sTest = ""
Do Until rsttmp.EOF
sTest = "NewName"
rsttmp.Edit
rsttmp.Fields("name") = sTest
rsttmp.Update
rsttmp.MoveNext
Loop
rsttmp.Close

Set rsttmp = Nothing
End Function

Function GetTablesWithSql()
Dim rsttmp As DAO.Recordset
Dim rstDav As DAO.Recordset
Dim sTest As String
Dim sql As String


sql = "Select * from results "

Set rsttmp = CurrentDb.OpenRecordset(sql)

sTest = ""
Do Until rsttmp.EOF
sTest = "NewName"
rsttmp.Edit
rsttmp.Fields("name") = sTest
rsttmp.Update
rsttmp.MoveNext
Loop
rsttmp.Close

Set rsttmp = Nothing
End Function


 
Thank You very much! I will give it a try. At least it gives me something to get started.
Much appreciated!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top