Ok, so I'm new to VB and Access (using 2000) and need some what I think is pretty basic help.
I have a table, it has a field I want to pull apart, process and use that information to populate other fields.
I've used a connection and a recordset to pull out the information, been able to process it fine, and print it to my immediate window the VB area, but now I want to save it back to the table and am not sure where to go with that... any hints? Below is the code I'm using.
Follow up question, if I wanted to convert my integers to characters such that all entries were two digits (i.e. 01, 02...) how would I go about that in VB?
Thanks,
Rob
Option Compare Database
Sub convertandadd()
Dim cnn As Connection
Dim rsTester As New ADODB.Recordset
Set cnn = CurrentProject.Connection
rsTester.Open "tester", cnn, adOpenKeyset, adLockBatchOptimistic, adCmdTableDirect
While Not rsTester.EOF
temp = rsTester.Fields("tendigid"
temp12 = Math.Round((temp / 100000000) - 0.5)
temp34 = Math.Round((temp / 1000000) - 0.5) - (temp12 * 100)
temp56 = Math.Round((temp / 10000) - 0.5) - (temp34 * 100) - (temp12 * 10000)
temp78 = Math.Round((temp / 100) - 0.5) - (temp56 * 100) - (temp34 * 10000) - (temp12 * 1000000)
temp910 = temp - temp78 * 100 - temp56 * 10000 - temp34 * 1000000 - temp12 * 100000000
Debug.Print temp12
rsTester.MoveNext
Wend
rsTester.Close
cnn.Close
End Sub
I have a table, it has a field I want to pull apart, process and use that information to populate other fields.
I've used a connection and a recordset to pull out the information, been able to process it fine, and print it to my immediate window the VB area, but now I want to save it back to the table and am not sure where to go with that... any hints? Below is the code I'm using.
Follow up question, if I wanted to convert my integers to characters such that all entries were two digits (i.e. 01, 02...) how would I go about that in VB?
Thanks,
Rob
Option Compare Database
Sub convertandadd()
Dim cnn As Connection
Dim rsTester As New ADODB.Recordset
Set cnn = CurrentProject.Connection
rsTester.Open "tester", cnn, adOpenKeyset, adLockBatchOptimistic, adCmdTableDirect
While Not rsTester.EOF
temp = rsTester.Fields("tendigid"
temp12 = Math.Round((temp / 100000000) - 0.5)
temp34 = Math.Round((temp / 1000000) - 0.5) - (temp12 * 100)
temp56 = Math.Round((temp / 10000) - 0.5) - (temp34 * 100) - (temp12 * 10000)
temp78 = Math.Round((temp / 100) - 0.5) - (temp56 * 100) - (temp34 * 10000) - (temp12 * 1000000)
temp910 = temp - temp78 * 100 - temp56 * 10000 - temp34 * 1000000 - temp12 * 100000000
Debug.Print temp12
rsTester.MoveNext
Wend
rsTester.Close
cnn.Close
End Sub