Need to trigger form insert event (1 Viewer)

DemonDNF

Registered User.
Local time
Today, 13:20
Joined
Jan 31, 2014
Messages
77
I don't know if this is possible from VBA.

I have a main Part form and a Spec subform linked via Part key.

I need to add 6 Spec records automatically when a new Part is added so user can select desired Specs (default value is "n/a" for al 6 entries).



Right now I have the Spec entries added in AfterInsert for Part form, but I have to navigate out and back into record to trigger Part insert. I cannot add the Spec entries until the Part entry is added.

Is a command button my only option? Or is there another way?

AfterInsert is too late, and BeforeInsert is too early; that gets triggered as soon as the first character is typed in Part name.

(dazed and confused)

Robert
 

JHB

Have been here a while
Local time
Today, 19:20
Joined
Jun 17, 2012
Messages
7,732
Is a command button my only option? Or is there another way?
There are other ways, the "problem" here is to tell the program when you are finish inputting text in the "Part" control.
Let's say you always finish the inputting part by hitting "Return", then you can test for the "Return" character code.
Code:
Private Sub ThePartControlName_KeyDown(KeyCode As Integer, Shift As Integer)
  If KeyCode = 13 Then
    'Run you code here
    
    'Release the normal behaviour for Return
    KeyCode = 0
  End If
End Sub
 

DemonDNF

Registered User.
Local time
Today, 13:20
Joined
Jan 31, 2014
Messages
77
I've been pulling out my hair trying to figure how to use IF PartName <> PreviousPartName when PartName lost focus; it quickly became a nightmare.


EDIT 2: Solved! Checking for keypress set me on right track, added a shared table checking module that reduced complexity.

Robert
 
Last edited:

Users who are viewing this thread

Top Bottom