Solved

need some more simple VB code for an access form

Posted on 2004-09-22
10
133 Views
Last Modified: 2010-05-02
I have a combo box set up with the standard code in the 'on not found' event to open up another form so the user can fill out that form, and then goes back and requeries the combo box.

I dont like the fact that when the user types in his value in the combo box, he/she has to retype the exact same value for the related field in the new box.  I need it to send the value the user typed to the new text box in the new form.

Thanks.
0
Comment
Question by:salival
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +1
10 Comments
 
LVL 3

Assisted Solution

by:gillgates
gillgates earned 166 total points
ID: 12124608
Suppose your new form is call form2 and the textbox on the form it textbox2

form2.textbox2.SetFocus
form2.textbox2.Text = "The Text"
0
 
LVL 32

Accepted Solution

by:
Erick37 earned 167 total points
ID: 12124609
One way:

In the new form:

Form_Load

  Me.Text1.Text = frmMain.Combo1.Text  'where frmMain is the form which opened this form
0
 

Author Comment

by:salival
ID: 12125349
i added the code, and i get an error message when loading the new form telling me 'variable not defined' and it highlights the "frmMain" name in my code
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 32

Expert Comment

by:Erick37
ID: 12125366
Replace "frmMain" with the name of your main form, it's set to Form1 by default.
0
 
LVL 3

Expert Comment

by:gillgates
ID: 12125400
If you can't get that working you could always save it in a global variable and then on form_load of your new form just set the textbox.Text to that variable.
0
 

Author Comment

by:salival
ID: 12125467
yeah, i changed the name (im not that clueless).  Have no clue why it wouldnt be working.    The original form that is calling the second form is a subform within another form, but i dont think that has anything to do with it.
0
 
LVL 32

Expert Comment

by:Erick37
ID: 12125572
This will work:

From your calling form:

Form2.Text1.Text = Me.Combo1.Text
Form2.Show


where Form2 is the new form to be shown
0
 
LVL 4

Assisted Solution

by:Prestaul
Prestaul earned 167 total points
ID: 12126939
You can use the OpenArgs property for this.  This is exactly what it is intended for.

1) Modify your "on not found" event code so that it looks something like:

DoCmd.OpenForm FormName:="FormName", OpenArgs:=ComboBox.Text

2) Put something like the following in your Form_Load event on the second form:

If Not IsNull(Me.OpenArgs) Then TextBox.Text = Me.OpenArgs
0
 

Author Comment

by:salival
ID: 12136437
sorry guys.  i had to take some time away from it and move onto something else.

the trick is, at least in access 97, it has to be Forms!frmMain.text
0
 
LVL 4

Expert Comment

by:Prestaul
ID: 12136460
You don't have to worry about referencing the form (except to launch it) if you use the OpenArgs method I showed above.
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month7 days, 9 hours left to enroll

632 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question