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

Form Function/Macro Help

Status
Not open for further replies.

hughed00

Technical User
Jan 15, 2001
43
0
0
US
I have to calculate a check digit from a 12 digit code. Each digit needs to have an arithmatic operation done on it.

My first hurdle, how do I get the 12 digit number into another table with each digit in its own field (so I can then go to work on them).

I thought I will likely have to convert to text, but really don't know where to start.

Thanks
 
try this:

dim i as integer
dim db as database
dim rs as recordset
dim sValue as string

set db = currentdb
set rs = dp.opendatabase("Table",dbopendynaset)
sValue = "12 digit code"

for i = 1 to 12

rs.addnew
rs.fields(0) = mid$(sValue,i,1)
rs.update


next i

Nick
 
Hi!

If the number is entered on a form you can use this code in the after update event procedure:

Dim strCheckNumber As String
Dim rst As DAO.Recordset

Set rst = CurrentDb.OpenRecordset("tblDigits", dbOpenDynaset)

strCheckNumber = YourTextBox.Value

With rst
.AddNew
!FirstField = CInt(Mid(strCheckNumber, 1, 1))
!SeconField = CInt(Mid(strCheckNumber, 2,1))
etc.
.Update
End With

hth
Jeff Bridgham
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top