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

Procedure Not Increasing Correctly 3

Status
Not open for further replies.

quest4

Technical User
Aug 27, 2001
735
US
Good afternoon. I have a OnKeyDown event procedure, which when CTRL-b is pressed It increase the value of PartGroup by one. It is not increasing it at all. Can someone please look at this code and tell me what I did wrong?
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Dim ControlDDown As Integer
ControlDDown = (KeyCode = vbKeyD And Shift And acCtrlMask) > 0

If ControlDDown = True Then
Me!PartGroup = Me!PartGroup + 1
Me!ItemNumber = Nz(DMax("[ItemNumber]", "stblECN_BOM", "[PartGroup] = " & Me!PartGroup), 0) + 1
End If
End Sub
I haven't gotten far enoughto know if it is resetting ItemNumber to to 1 yet. Thank you very much to anyone who helps straighten this out
 
Thank you for the reply, Tony. I did some experimenting over the weekend, I am beginning to think I shouldn't have, but here goes. Here is the code that controls the initial numbering:
Private Sub Form_BeforeInsert(Cancel As Integer)
If IsNull(Me!PartGroup) Then
Me!PartGroup = Nz(DMax("[PartGroup]", "stblECN_BOM"), 1)
End If
If IsNull(Me!ItemNumber) Then
Me!ItemNumber = Nz(DMax("[ItemNumber]", "stblECN_BOM", "[PartGroup] = '" & Me!PartGroup) & "'", 0) + 1
End If
End Sub
This works fine by it self, but when the code below is added, the ItemNumber code in either procedure stop function and start run-time erroring. Here is the the second part:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Dim ControlBDown As Integer
ControlBDown = (KeyCode = vbKeyB And Shift And acCtrlMask) > 0
If ControlBDown = True Then
Me!PartGroup = Nz(DMax("[PartGroup]", "stblECN_BOM")) + 1
Me!ItemNumber = Nz(DMax("[ItemNumber]", "stblECN_BOM", "[PartGroup] = " & Me!PartGroup), 0)
End If
End Sub
The Groups appear to be working correctly, but it is hard to tell. Why is ItemNumber not working? Thank you again for your assistance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top