Make data entry depending on which button is clicked (1 Viewer)

Zydeceltico

Registered User.
Local time
Today, 09:30
Joined
Dec 5, 2017
Messages
843
Hi all -

Here's another one.

I have taken the suggestion of adding an InspectionType field in my main table, tblInspectionEvent which frmInspectionEvent is based on.

The values for InspectionType could be presented as a combobox with an attached Value List or pointing at a lookup table where I would have fields InspectionType_ID (autonumber) and InscpectionType (short text).

I've done this because I can now see how I could use that field later to build queries based on a specific type of inspection easier than trying to derive that from a more complicated query.

So - on frmInspectionEvent I have multiple buttons that open various inspection forms (e.g., Mill, WeldAssemble, Fabricate, Paint, etc).

If I add a textbox control to frmInspectionEvent, is it possible to code the form so that when one of the buttons is clicked to open a form that the textbox bound to InspectionType receives the InspectionType_ID associated with that specific "Open Form" button?

Something like:

If button "Mill Inspection" is clicked, InspectionType = 1
Else If button "WeldAssemble" is clicked, InspectionType = 2
Else If button...................

Is something like that possible?

Thanks,

Tim
 

Ranman256

Well-known member
Local time
Today, 09:30
Joined
Apr 9, 2015
Messages
4,339
each button would have its own code:

Code:
sub btnWeld_click()
docmd.openform "frmWeld", , , , acFormAdd
forms!frmWeld!txtInspectType =2
end sub

or use 1 form for all , and pick the InspectionType from a combo box.
 

Zydeceltico

Registered User.
Local time
Today, 09:30
Joined
Dec 5, 2017
Messages
843
each button would have its own code:

Code:
sub btnWeld_click()
docmd.openform "frmWeld", , , , acFormAdd
forms!frmWeld!txtInspectType =2
end sub

or use 1 form for all , and pick the InspectionType from a combo box.

That will work well. Thank you. I have a tendency to overthink things! :)

I was trying to avoid using a secondary combo box. I believe your code does it.
 
Last edited:

jdraw

Super Moderator
Staff member
Local time
Today, 09:30
Joined
Jan 23, 2006
Messages
15,362
For consideration, you might click on Inspection and get a list/combo of valid InspectionTypes; select the one that applies; then

with a select case construct
Code:
Select Case InspectionType  (where integers represent your inspection types)
 Case 1
       DoCmd.OpenForm  "frmMill"........ other parms
 Case 2
       DoCmd.OpenForm  "frmWeld"........ other parms
Case 3
       DoCmd.OpenForm  "frmPaint"........ other parms
.....
.....
Case Else
      MsgBox "unknown inspection type'
Ens Select
 
Last edited:

Zydeceltico

Registered User.
Local time
Today, 09:30
Joined
Dec 5, 2017
Messages
843
For consideration, you might click on Inspection and get a list/combo of valid InspectionTypes; select the one that applies; then

with a select case construct
Code:
Select Case InspectionType  (where integers represent your inspection types)
 Case 1
       DoCmd.OpenForm  "frmMill"........ other parms
 Case 2
       DoCmd.OpenForm  "frmWeld"........ other parms
Case 3
       DoCmd.OpenForm  "frmPaint"........ other parms
.....
.....
Case Else
      MsgBox "unknown inspection type'
Ens Select

I really like that approach. WOuld that code go on the AFter Update event of the cbo should I choose use that?
 

jdraw

Super Moderator
Staff member
Local time
Today, 09:30
Joined
Jan 23, 2006
Messages
15,362
That's where I'd put it.
You have already clicked Inspection, now you choose which Inspection Type; Then you open the appropriate form to do your info entry...

Good luck.
 

Zydeceltico

Registered User.
Local time
Today, 09:30
Joined
Dec 5, 2017
Messages
843
That's where I'd put it.
You have already clicked Inspection, now you choose which Inspection Type; Then you open the appropriate form to do your info entry...

Good luck.

And the added bonus of a lot more screen real estate. Thanks for thinking to mention it.
 

Users who are viewing this thread

Top Bottom