Form not allowing Additions

G

Gordon Foster

Hi,

I have a subform to input serial numbers into. Sometimes we only need 1
serial number per item and sometimes more therefore I have made my code
lookup how many I need for the 'kit number' selected on the main form and if
I reach that limit I navigate the main form to a new record. I do this in
the AfterUpdate event. It works fine if I only need 1 serial number for a
particular kit. Here is a scenario of the problem if I need 2 serial
numbers:

On the subform...
I scan a serial number and the main form does not go to a new record (as it
should, I only have 1 serial number so far)
I scan a serial number and the main form does go to a new record (as it
should, I've reached the 2 serial number limit)
I scan a serial number and the main form does not go to a new record (as it
should)
....but now I can't add another serial number. For some reason in the
datasheet subform when you start typing the first serial number the next
record box does not show up (with the * in the record selector) as it
normally does. The subform loses it's focus after pressing enter and the
focus goes to a control on the main form. The only way I can add the next
serial is to navigate away from the item and come back. At the point that
it screws up it is almost like the AllowAdditions property has been set to
False.

Any help would be appreciated, below is the code for the AfterUpdate event.

Gordon Foster

Private Sub Serial_Numbers_AfterUpdate()
Dim intSerialsAllowed As Integer 'number of serials needed for a
kit number
Dim intSerialsScanned As Integer 'number of serials currently in
recordset

'force the record to be saved so gathered values are up to date
Me.Dirty = False

intSerialsScanned = Me.RecordsetClone.RecordCount
intSerialsAllowed = HowManySerialsNeededFor(Me.Parent!kitnumberid)

'if we have them all then navigate to the next item
If intSerialsScanned = intSerialsAllowed Then
lngKitNumberID = Me.Parent.kitnumberid 'get current product
selected
Me.Parent.Recordset.AddNew 'navigate user to next
item
Me.Parent.kitnumberid = lngKitNumberID 'set the product to same
as before
Me.Parent.Dirty = False 'parent must have a
saved record
End If

End Sub
 
G

Gordon Foster

Another thing that I have noticed about this is that whenever I add a new
record to the main form through code the AutoNumber field in the main forms
table is being incremented by 2 for some reason.

Gordon Foster


<<snip>>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top