New Record = 1,000 blank records? (1 Viewer)

Chrisopia

Registered User.
Local time
Today, 00:47
Joined
Jul 18, 2008
Messages
279
urm, yeah... I've been tackling with a form for a while and kept coming up with a "cannot go to specific record" error... I decided to check in the tables to start again - and it turns out it adds nearly 1,000 blank records before giving me the error. - so after deleting nearly 100,000 blank records I've gone through my code to see if there are any loops or traps... and I can't see any?

Code:
Private Sub Form_Current()
Me.[Quote or Invoice] = "I"
Me.Recordset.AddNew 'makes subform blank
NewForm
End Sub

Private Sub Form_Load()
Me.[Quote or Invoice] = "I"
Me.Recordset.AddNew 'makes sub form blank
NewForm
End Sub

Public Sub NewForm()
CustomerID = "1"

Me.Z1Number.SetFocus

Me.CASH.Enabled = False
Me.CARD.Enabled = False
Me.CHEQUE.Enabled = False

Me.LCDtxt = "N"
End Sub

Public Sub TillOpen()
 Me.Date_Paid = Now()
 Me.Refresh
 DoCmd.OpenReport "Report1", acViewNormal, , "InvoiceID = " & Me.InvoiceID
    SaleEnd
 End If

Public Sub SaleEnd()

Me.LCDtxt = "END"
Me.Z1Number.SetFocus
Me.Refresh
Me.Dirty = False
DoCmd.GoToRecord , , acNewRec

End Sub

On Load = blank out subform, continue to NewForm. (On Current - occurs on page navigation)
NewForm = set customer ID, changes focus
TillOpen - activated after a transaction = stamps date, works out if change is required or not, saves info, prints receipt, sale end
SaleEnd = Change text until something happens, changes focus, saves info, clears dirty, *tries to go to next record

I don't know why it thinks it needs to add 1,000 records?
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 08:47
Joined
Sep 12, 2006
Messages
15,696
i think all the addnews cannot help. i would take those out

if this form is just to manage new items, change it to DATAENTRY.

then each session is effectively a set of new entries - and you won;t see the previous ones.
 

jkl0

jkl0
Local time
Today, 03:47
Joined
Jun 23, 2006
Messages
192
Because you are adding a new record under Form_Current() and under Form_Load(), I think those 2 events are firing back and forth at each other.

I agree with gemma-the-husky. Just to make the form data entry and eliminate the Form_Current() and Form_Load() procedures.
 

Chrisopia

Registered User.
Local time
Today, 00:47
Joined
Jul 18, 2008
Messages
279
Thanks guys! Yes - it was an issue with Form_Current() - I assumed I needed it because a new form page was being navigated to.
I will look into data entry and keep my code concise. Thanks!!
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 03:47
Joined
Feb 19, 2002
Messages
43,466
With bound forms, Access takes care of adding new rows when necessary. You never need code for that.
 

Users who are viewing this thread

Top Bottom