Solved

need some more simple VB code for an access form

Posted on 2004-09-22
10
129 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
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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
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…

772 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