Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I trigger event on form1 from form2 (not subform) to change rst 1

Status
Not open for further replies.

TKaminski

Programmer
Sep 5, 2001
27
US
For the easy of discussion I have simplified my code to simplier example.

I have a form named (frmCustomerActivity) with a command button named (cmdShowAllInvoices) which opens a second form named (frmShowAllCustomerInvoices). This second form is set a Pop Up with border style set to dialog. The user selects a customer invoice from a list box on this second form (frmShowAllCustomerInvoices) and I want to move the first form to the selected invoice(record).

I am able to write the selected record number back to the first form, into a text box who’s After Update event call code that will move the user to that record. The code triggered by this event works as desired when the user changes this text boxes value while still on the first form. However, I have just learned the painful news from the VBA/Access help file that this event, and other similar events, do not get triggered when the text box's data is changed via VBA code.

Help. I am stuck.

As a work around attempt I tried putting a transparent cmdButtom on the first form (frmCustomerActivity) and then tried to trigger its On Click event by setting focus on this transparent button from the second form and then using a SendKeys code to send an “{ENTER}” to ‘click’ this button, but the “{ENTER}” ends up being sent to the second form (frmShowAllCustomerInvoices), the place it originated from, and not being received on the desired first form.

I am open to any good strategy to meet this goal. I cannot add any more subform to the first form since screen space is very full already.
 
I would simply add a public method to the form so you can call it from anywhere:
Code:
[green]'main form module[/green]
Public Sub GotoInvoice(ByVal strInvoice As String)
  [green]'add your lookup and bookmark code here[/green]
End Sub
In the popup form, you can call the main form's method:
Code:
[green]'popup form[/green]
Private Sub cmdDone_Click()
  Forms!MainForm.GotoInvoice(Me!lstInvoice)
  DoCmd.Close acForm, Me.Name
End Sub

VBSlammer
redinvader3walking.gif

"You just have to know which screws to turn." - Professor Bob
 
WOW VBSlammer! You are a hero! Have a star and a great day.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top