Click or tab to textbox and open popup (1 Viewer)

isladogs

MVP / VIP
Local time
Today, 03:37
Joined
Jan 14, 2017
Messages
18,209
You're welcome
 

Zydeceltico

Registered User.
Local time
Yesterday, 22:37
Joined
Dec 5, 2017
Messages
843
MajP - Yes! This code will be very useful going forward.

Thank you very much!

Tim
 

Zydeceltico

Registered User.
Local time
Yesterday, 22:37
Joined
Dec 5, 2017
Messages
843
So here's one for you.

I copied/pasted frmMeasurement and renamed the two copies frmAssemblyAL and frmAssemblyRL. I changed the code to reflect the changes.

Each works seperately and returns the correct number to the correct field. However, if I click the Length Required button on the main form first, enter data, and save/exit it populates the field correctly. Then the user would move on to click the button labelled Actual Length and enter that data. Well.....the form opens, I can enter data, but when I click save/exit the Actual Length field on frmWeldAssemblyInspections does not populate.

However - and this is the interesting part - if I enter data in reverse order (i.e., Actual Length first and Required Length second) both fields populate correctly with the correct numbers.

What might this be due too?

Thanks,

Tim
 

Attachments

  • Capture.JPG
    Capture.JPG
    88.9 KB · Views: 68
  • QC DB Mockup_CR.accdb
    924 KB · Views: 68

Zydeceltico

Registered User.
Local time
Yesterday, 22:37
Joined
Dec 5, 2017
Messages
843
Figured it out. Another typo. Like I said in my OP, I know just enough to be a problem. :D
 

isladogs

MVP / VIP
Local time
Today, 03:37
Joined
Jan 14, 2017
Messages
18,209
For info, you don't need two forms frmMeasurement

Instead you open the same form with different arguments (OpenArgs) for Length Required & Length Actual
See attached
 

Attachments

  • QC DB Mockup_CR_v2.zip
    80.2 KB · Views: 70

Zydeceltico

Registered User.
Local time
Yesterday, 22:37
Joined
Dec 5, 2017
Messages
843
Question: what are the 6 commas for? Placeholders for more arguments?
 

Attachments

  • Capture.JPG
    Capture.JPG
    41.8 KB · Views: 73

isladogs

MVP / VIP
Local time
Today, 03:37
Joined
Jan 14, 2017
Messages
18,209
Question: what are the 6 commas for? Placeholders for more arguments?

Yes. Syntax is :
DoCmd.OpenForm(FormName, View, FilterName, WhereCondition, DataMode, WindowMode, OpenArgs)

In the VBE, click on OpenForm then press the F1 key to open Access help.
This will give more info on each argument
 

MajP

You've got your good things, and you've got mine.
Local time
Yesterday, 22:37
Joined
May 21, 2018
Messages
8,525
The following code will pull information from any pop up form, so you can reuse it. I usually write a pop up form once and reuse it many places.

Code:
Public Function getValueFromPopUp(formName As String, PopUpControlName As String) As Variant
  'FormName: Name of the popup form
  'PopupControlName: Name of the control on the pop up/dialog that you want the value
  Dim frm As Access.Form
  DoCmd.OpenForm formName, , , , acFormEdit, acDialog
  'wait until form is closed or hidden
  'The popup needs an OK button that hides the popup(me.visible = false), and a Cancel button that just closes it
  If CurrentProject.AllForms(formName).IsLoaded Then
    Set frm = Forms(formName)
    getValueFromPopUp = frm.Controls(PopUpControlName).Value
    DoCmd.Close acForm, formName
  End If
End Function

On any popup form that returns a value I have two buttons. OK and Cancel
The OK button has the code
Code:
Me.Visible = False
The cancel button simply closes out the form

So then you can pull a value from any popup by

Code:
 Dim rtn As Variant
  rtn = getValueFromPopUp("YourFormName", "YourControlName")
  If Not Trim(rtn & " ") = "" Then
    something = rtn
  End if
 

Users who are viewing this thread

Top Bottom