Programatically Run After Update for Combo (1 Viewer)

sxschech

Registered User.
Local time
Today, 06:13
Joined
Mar 2, 2010
Messages
792
Trying to figure out how to take a value in Form1 datasheet view using double click event and pass it to combobox on Form2 and have afterupdate event of Form2 run as if user manually selected the value in the combobox on Form2.

This seems to get the data from Form1 and run the appropriate code in Form2, generates an error. When I look at code it shows that the combobox value is null, so is not getting the data from the other form. It does not show up in the combobox either.
Col 0 of combo is ID hidden, Col 1 is the visible value that should match the text passed from Form2.

In debug mode
forms!frmnewproduct.cboacro.value shows the correct value, but forms!frmnewproduct.cboacro.column(1) shows null, so while data passed to the other form, it is not populating the columns in the combobox. Need to use the columns in the combobox in order to run the afterupdate event.

Code:
Private Sub Acronym_DblClick(Cancel As Integer)
'Goto this event
    Forms!frmNewProduct.cboAcro.Value = Me.Acronym
    Forms!frmNewProduct.SetFocus
    Forms!frmNewProduct.cboAcro_AfterUpdate
End Sub
 

isladogs

MVP / VIP
Local time
Today, 14:13
Joined
Jan 14, 2017
Messages
18,207
Which is the bound column in the combobox?
 

sxschech

Registered User.
Local time
Today, 06:13
Joined
Mar 2, 2010
Messages
792
Bound Column of Combobox is 1
Combobox is unbound to form
RowSource of ComboBox
Code:
SELECT CC.ID, CC.Acronym, CC.EventCode, CC.EventTitle, CC.StartDate, CC.V06_FDNAUTHORS, CC.V06_FDNINSTRUCTORS FROM SS_basic_event_data_Courses_Conferences AS CC INNER JOIN PREPPING ON CC.EventCode = PREPPING.EVENTCODE WHERE Right(CC.EVENTCODE, 1) = 'A' ORDER BY CC.[Acronym]
Data trying to pass from other form is a text box on datasheet view bound to Accronym. Datasource is another sql statement, only common field is acronym, (different from the sql statement above).
 

isladogs

MVP / VIP
Local time
Today, 14:13
Joined
Jan 14, 2017
Messages
18,207
Sorry but I keep reading this and am confused by what your two posts are saying.

Every time I read it, it seems to mean something else - mind you it is late here so it might just be me!

Can you upload a stripped down version with the 2 forms & relevant records & I'll look at it tomorrow
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 14:13
Joined
Jul 9, 2003
Messages
16,269
Sounds to me like you want to mimic the after update event after you open the form from the control. I spoke about it in this video, it might be worth a look:-

https://youtu.be/8bt4DVVFO0s

Sent from my SM-G925F using Tapatalk
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 14:13
Joined
Jul 9, 2003
Messages
16,269
On reading your question again I realise you want the after update event to run in the Called Form..

The approach I would use would be to create a public function in the called form, fUpdateCombo(strPassedValue as String)

Me.ComboToUpdate.Value = strPassedValue

'Put the code here you want to be like the after update event.

End Function ' fUpdateCombo

Sent from my SM-G925F using Tapatalk
 
Last edited:

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 14:13
Joined
Jul 9, 2003
Messages
16,269
In the Calling form, the double click event would be something like:-

Forms_frmYourFrmName.fUpdateCombo(Me.cboYourCombo.Value)

I'm tapping this in on me phone, so it's will need some correction.

Sent from my SM-G925F using Tapatalk
 

sxschech

Registered User.
Local time
Today, 06:13
Joined
Mar 2, 2010
Messages
792
Thank you both for replying, didn't expect to receive assistance so late in the day.

Uncle Gizmo: Will have to try your suggestion on Monday. Before posting I did searches and most were related to your original suggestion of the open form, but as this is a case where both forms are open, that didn't seem to apply. Glad you took another read of the issue and provide possible syntax for calling the sub.

Ridders, if after trying UG's suggestion I still have issues, I'll post the db as requested. Sorry if that haven't been able to articulate well what the concept is.
 

sxschech

Registered User.
Local time
Today, 06:13
Joined
Mar 2, 2010
Messages
792
I tried Uncle Gizmo's suggestion and must be missing something because it still isn't populating the combobox, error message invalid use of null. I hovered mouse over the part in parens of
Forms!frmnewproduct.fUpdateCombo (Me.Acronym.Value)
and it does show the value I double clicked on. I made a copy of the file and deleted data to put up, but must have deleted too much as the form didn't pull up data. So rather than figure out which items I need to keep/alter, hoping a few screen shots plus the code I entered will be sufficient.

I put this code in frmMissing which is the form the user will double click on:
Code:
Private Sub Acronym_DblClick(Cancel As Integer)
'Goto this event
     [B][COLOR=Red] Forms!frmnewproduct.fUpdateCombo (Me.Acronym.Value)[/COLOR][/B]
End Sub
I put this code in frmNewProduct
Code:
Public Sub fUpdateCombo(stPassedValue As String)
    Me.cboAcro.Value = stPassedValue
    Call cboAcro_AfterUpdate
End Sub

[COLOR=DimGray]Public Sub cboAcro_AfterUpdate()
'Create a new product and prompt for
'input that is not available via net forum
'20170307
'Add new/Edit Product to the workflow
    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Dim stsql As String
    Dim stEventCode As String
    Dim stDirectoryPath As String
    Dim yesno
    
    Set db = CurrentDb
    Set rs = db.OpenRecordset("PREPPING", dbOpenDynaset)
     
    stEventCode = Me.cboAcro.Column(2)
    Select Case Me.lstEdit
...
more code
...
End Sub[/COLOR]
Screenshots:
Acro1 - This is where user keys in the Acro
Acro2 - User clicks on Missing Items in listbox, which opens frmMissing
Acro3 - User double clicks on acronym, this should then populate the acronym combobox on frmProducts and bring up the details as if the user manually clicked on the acronym combobox
 

Attachments

  • WorkFlowByAcro1.PNG
    WorkFlowByAcro1.PNG
    39.8 KB · Views: 62
  • WorkFlowByAcro2.PNG
    WorkFlowByAcro2.PNG
    39.9 KB · Views: 60
  • WorkFlowByAcro3.PNG
    WorkFlowByAcro3.PNG
    55.9 KB · Views: 62

Users who are viewing this thread

Top Bottom