|
-
Jul 19th, 1999, 09:33 PM
#1
why doesn't this code work?
there is one textbox where a number is entered and then i want to write that number and date and time and another date to table.
Private Sub txtOrdNo_AfterUpdate()
Dim db As Database
Dim rs As Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("Billing_Audit", dbOpenTable)
While Not rs.EOF
rs.AddNew
rs("Invoice_Date") = Me.txtDate
rs("Order_No") = Me.txtOrdNo
rs("Date_Scanned") = Format(Now, "yyyymmdd")
rs("Time_Scanned") = Format(Now, "hhnnss")
rs.Update
Wend
End Sub
-
Jul 19th, 1999, 10:06 PM
#2
Lively Member
Hi,
What happens when you try to run this code? Are there any error messages or anything?
Preeti
-
Jul 19th, 1999, 10:50 PM
#3
runtime error 3022:
changes you requested weren't successful because they would create duplicate values in the index, primary key, etc...
the i click debug and
rs.Update
is highlighted
any thoughts?
-
Jul 20th, 1999, 01:33 AM
#4
thankx preeti,
that did it...now it works!
ever grateful,
larryn
-
Jul 20th, 1999, 11:59 AM
#5
Lively Member
Hi,
The field that you have declared as your primary key can only have one instance of a value. You are trying to add an existing value into your database.
Put a watch on the value that is going into your primary key field and see if the value you are trying to insert already exists in the database.
Also, remove the while loop. I am assuming that you are tyring to insert this record only once so you do not need to keep on inserting until you reach the end of the table.
HTH,
Preeti
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|