Solved

need some more simple VB code for an access form

Posted on 2004-09-22
10
126 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
  • 3
  • 3
  • 2
  • +1
10 Comments
 
LVL 3

Assisted Solution

by:gillgates
gillgates earned 166 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 32

Expert Comment

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

Expert Comment

by:gillgates
Comment Utility
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

Author Comment

by:salival
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now