Go Back   Access World Forums > Microsoft Access Discussion > Forms

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 05-19-2017, 03:01 PM   #1
sxschech
Newly Registered User
 
Join Date: Mar 2010
Posts: 404
Thanks: 10
Thanked 77 Times in 68 Posts
sxschech is on a distinguished road
Programatically Run After Update for Combo

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

sxschech is offline   Reply With Quote
Old 05-19-2017, 03:04 PM   #2
ridders
AWF VIP
Gold Supporter
 
ridders's Avatar
 
Join Date: Jan 2017
Location: Somerset, UK
Posts: 1,615
Thanks: 28
Thanked 359 Times in 334 Posts
ridders will become famous soon enough ridders will become famous soon enough
Re: Programatically Run After Update for Combo

Which is the bound column in the combobox?
__________________
Colin
Access 2010 32-bit, Access 2016 32-bit & 64-bit, SQL Server Express 2014, Windows 10,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
, Tapatalk


If this answer has helped, please click the Thanks button and/or click the 'reputation' scales symbol on the left and leave a comment. Cheers!
ridders is offline   Reply With Quote
Old 05-19-2017, 03:22 PM   #3
sxschech
Newly Registered User
 
Join Date: Mar 2010
Posts: 404
Thanks: 10
Thanked 77 Times in 68 Posts
sxschech is on a distinguished road
Re: Programatically Run After Update for Combo

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).

sxschech is offline   Reply With Quote
Old 05-19-2017, 03:57 PM   #4
ridders
AWF VIP
Gold Supporter
 
ridders's Avatar
 
Join Date: Jan 2017
Location: Somerset, UK
Posts: 1,615
Thanks: 28
Thanked 359 Times in 334 Posts
ridders will become famous soon enough ridders will become famous soon enough
Re: Programatically Run After Update for Combo

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
__________________
Colin
Access 2010 32-bit, Access 2016 32-bit & 64-bit, SQL Server Express 2014, Windows 10,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
, Tapatalk


If this answer has helped, please click the Thanks button and/or click the 'reputation' scales symbol on the left and leave a comment. Cheers!
ridders is offline   Reply With Quote
Old 05-19-2017, 05:24 PM   #5
Uncle Gizmo
Nifty Access Guy
 
Uncle Gizmo's Avatar
 
Join Date: Jul 2003
Location: Newbury Berks UK
Posts: 8,604
Thanks: 236
Thanked 636 Times in 607 Posts
Uncle Gizmo has a spectacular aura about Uncle Gizmo has a spectacular aura about Uncle Gizmo has a spectacular aura about
Send a message via Skype™ to Uncle Gizmo
Re: Programatically Run After Update for Combo

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
__________________
............

Answering questions on AWF has given me an insight into the difficulties in programming with MS Access. Often, idea's for my YouTube video's originate from this experience. My forte is in presenting the solution in video format. Please take this opportunity to join My YouTube channel ---
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Uncle Gizmo is offline   Reply With Quote
Old 05-19-2017, 05:33 PM   #6
Uncle Gizmo
Nifty Access Guy
 
Uncle Gizmo's Avatar
 
Join Date: Jul 2003
Location: Newbury Berks UK
Posts: 8,604
Thanks: 236
Thanked 636 Times in 607 Posts
Uncle Gizmo has a spectacular aura about Uncle Gizmo has a spectacular aura about Uncle Gizmo has a spectacular aura about
Send a message via Skype™ to Uncle Gizmo
Re: Programatically Run After Update for Combo

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
__________________
............

Answering questions on AWF has given me an insight into the difficulties in programming with MS Access. Often, idea's for my YouTube video's originate from this experience. My forte is in presenting the solution in video format. Please take this opportunity to join My YouTube channel ---
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Last edited by Uncle Gizmo; 05-19-2017 at 05:40 PM.
Uncle Gizmo is offline   Reply With Quote
Old 05-19-2017, 05:37 PM   #7
Uncle Gizmo
Nifty Access Guy
 
Uncle Gizmo's Avatar
 
Join Date: Jul 2003
Location: Newbury Berks UK
Posts: 8,604
Thanks: 236
Thanked 636 Times in 607 Posts
Uncle Gizmo has a spectacular aura about Uncle Gizmo has a spectacular aura about Uncle Gizmo has a spectacular aura about
Send a message via Skype™ to Uncle Gizmo
Re: Programatically Run After Update for Combo

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

__________________
............

Answering questions on AWF has given me an insight into the difficulties in programming with MS Access. Often, idea's for my YouTube video's originate from this experience. My forte is in presenting the solution in video format. Please take this opportunity to join My YouTube channel ---
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Uncle Gizmo is offline   Reply With Quote
Old 05-19-2017, 06:42 PM   #8
sxschech
Newly Registered User
 
Join Date: Mar 2010
Posts: 404
Thanks: 10
Thanked 77 Times in 68 Posts
sxschech is on a distinguished road
Re: Programatically Run After Update for Combo

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 is offline   Reply With Quote
Old 05-22-2017, 09:20 AM   #9
sxschech
Newly Registered User
 
Join Date: Mar 2010
Posts: 404
Thanks: 10
Thanked 77 Times in 68 Posts
sxschech is on a distinguished road
Re: Programatically Run After Update for Combo

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
      Forms!frmnewproduct.fUpdateCombo (Me.Acronym.Value)
End Sub
I put this code in frmNewProduct
Code:
Public Sub fUpdateCombo(stPassedValue As String)
    Me.cboAcro.Value = stPassedValue
    Call cboAcro_AfterUpdate
End Sub

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
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
Attached Images
File Type: png WorkFlowByAcro1.PNG (39.8 KB, 11 views)
File Type: png WorkFlowByAcro2.PNG (39.9 KB, 12 views)
File Type: png WorkFlowByAcro3.PNG (55.9 KB, 11 views)

sxschech is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Programatically Update Table Tiffosi2007 Modules & VBA 2 03-14-2008 12:39 AM
Combo box performs query, update combo box with only result? Macinslaw Forms 2 08-04-2006 11:01 AM
How to select an item in COMBO BOX programatically? Bosch General 1 05-14-2005 05:28 AM
combo box to update two fields after update jemar707311 Forms 8 08-24-2001 07:22 AM
Programatically change the type of a control (combo to textbox) Alexandre Forms 2 03-01-2001 10:06 AM




All times are GMT -8. The time now is 10:46 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Sponsored Links

How to advertise

Media Kit


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World