473,785 Members | 2,333 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

passing from one form to the next

AccessIdiot
493 Contributor
I feel really dumb asking this but I'm not sure why it isn't working.

I have a form that has a text field. You type a number into the text field, it gets concatenated with a string, then gets put into the table as a string in the field "Survey_Num ".

Press a button on the form and another form pops up. There is a "Survey_Num " field in the table behind this form as well and they are tied in a one-to-many relationship.

I want the value on the first form to show up in the field on the 2nd form.

I am guessing that it is not showing up because technically the value hasn't entered the table from the first form.

How do I force Access to enter the data when I press the button to go to the second form? I've tried using a close command to close the first form when the 2nd form is opening, thinking that will enter the info into the table but no dice.

Seems simple but I am stumped - any ideas?

Any code I can provide?

Form 1 = frm_Survey with unbound field txt_SurveyNum where user enters an integer and invisible field txt_SurveyNumID that is bound to Survey_Num of Survey table.

txt_SurveyNum has LostFocus event:
Expand|Select|Wrap|Line Numbers
  1. Private Sub txt_SurveyNum_LostFocus()
  2.     Me.txt_SurveyNumID = Me.OpenArgs & Me.txt_SurveyNum
  3. End Sub
The OpenArgs is passed by another form that opens frm_Survey.

Form 2 = frm_Replicate with Survey_Num field and control source is field of same name in table. Because it is in a relationship with the field of same name in the other table I didn't think I'd have to put any special query or code on it?

thanks in advance for any help!
melissa
Mar 8 '07
16 1809
AccessIdiot
493 Contributor
*with sheepish grin* what's the code for the Open form event?
I have this
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Open(Cancel As Integer)
  2.     Me.Survey_Num = Me.OpenArgs
  3. End Sub
but I get an error

also can you explain the difference between the form load event and the form open event?
Mar 9 '07 #11
Rabbit
12,516 Recognized Expert Moderator MVP
You'll have to put it in the On Load event.

On Open occurs when the form opens but before the first record is displayed.
On Load occurs when the form opens and after the first record is displayed.

So what's happening is that you're trying to assign the value to something that doesn't exist yet.
Mar 9 '07 #12
AccessIdiot
493 Contributor
Thank you for the explanation. Now I have this on frm_Survey:
Expand|Select|Wrap|Line Numbers
  1. stDocName = "frm_Replicate"
  2.     DoCmd.OpenForm stDocName, , , , , , Me.Survey_Num
  3.     DoCmd.GoToRecord , , acNewRec
and this on frm_Replicate:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.     Me.Survey_Num = Me.OpenArgs
  3. End Sub
  4.  
  5. Private Sub btnNewReplicate_Click()
  6. On Error GoTo Err_btnNewReplicate_Click
  7.  
  8.     DoCmd.GoToRecord , , acNewRec
  9.     Me.Survey_Num = Me.OpenArgs
  10.  
  11. Exit_btnNewReplicate_Click:
  12.     Exit Sub
  13.  
  14. Err_btnNewReplicate_Click:
  15.     MsgBox Err.Description
  16.     Resume Exit_btnNewReplicate_Click
  17.  
  18. End Sub
but I am getting an error message "Can't go to specified record"
Mar 9 '07 #13
AccessIdiot
493 Contributor
Ugh I have to head home but I'll be back tomorrow!

Thanks for your help Rabbit, as always. :-)
Mar 9 '07 #14
AccessIdiot
493 Contributor
I got it to work - thank you so much! This is what finally did it:

on frm_Survey
Expand|Select|Wrap|Line Numbers
  1. Private Sub txt_SurveyNum_LostFocus()
  2.     Me.txt_SurveyNumID = Me.OpenArgs & Me.txt_SurveyNum
  3. End Sub
  4. ------------------------------------------------------------
  5. Private Sub btn_AddReplicate_Click()
  6. On Error GoTo Err_btn_AddReplicate_Click
  7.  
  8.     Dim stDocName As String
  9.     Dim stLinkCriteria As String
  10.  
  11.     stDocName = "frm_Replicate"
  12.     DoCmd.OpenForm stDocName, , , , , , Me.Survey_Num
  13.     'DoCmd.GoToRecord , , acNewRec
  14.  
  15.     DoCmd.Close acForm, "frm_Survey"
  16.  
  17. Exit_btn_AddReplicate_Click:
  18.     Exit Sub
  19.  
  20. Err_btn_AddReplicate_Click:
  21.     MsgBox Err.Description
  22.     Resume Exit_btn_AddReplicate_Click
  23.  
  24. End Sub
and on frm_Replicate:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2.     Me.Survey_Num = Me.OpenArgs
  3. End Sub
  4. -------------------------------------------------
  5. Private Sub btnNewReplicate_Click()
  6. On Error GoTo Err_btnNewReplicate_Click
  7.  
  8.     DoCmd.GoToRecord , , acNewRec
  9.     Me.Survey_Num = Me.OpenArgs
  10.  
  11. Exit_btnNewReplicate_Click:
  12.     Exit Sub
  13.  
  14. Err_btnNewReplicate_Click:
  15.     MsgBox Err.Description
  16.     Resume Exit_btnNewReplicate_Click
  17.  
  18. End Sub
I have continued questions about how to work backwards - to go from frm_Replicate back to frm_Survey and still have the 'TR' in the form but that's a question for a separate post when I get to it.

Thanks so much for all your help!
melissa :-)
Mar 9 '07 #15
Rabbit
12,516 Recognized Expert Moderator MVP
Glad you got it working. Sorry I didn't respond earlier, I just got into the office.
Mar 9 '07 #16
AccessIdiot
493 Contributor
No worries. You know how satisfying it is when you finally figure out something yourself!
Mar 9 '07 #17

Sign in to post your reply or Sign up for a free account.

Similar topics

5
5943
by: Paul | last post by:
I want to use sessions to cover myself in case the user switches off cookies so I am passing the session ID manually through a hidden input field. This is what I have so far. index.php page contains: <?php $_SESSION = ""; $_SESSION = "";
1
7789
by: Paul | last post by:
Hmmm, didn't seem to work. I have set session.use_cookies = 1 and session.use_trans_sid = 1 in my php.ini file. Index.php contains: ---------------------------------------------------------------------------- <?php ini_set("session.use_cookies", "off"); ini_set("session.use_trans_sid", "on"); session_start(); $_SESSION = ""; $_SESSION = ""; echo "<form method='POST' action='login.php'>
3
8741
by: Mike | last post by:
I have a mulitpage form that I do not record the information into a dbase until the end. I need to pass the field values form on form to the next. I have the code for automatically generating the 'hidden fields' but cannot figure out how to code it to automatically generate the assignment statements. For example:
3
3651
by: Jason | last post by:
Hi folks, I'm trying to create a section of a website with a unique file upload utility. The problem is that in most code and components I find to pass multipart/form data, you need to know the number of files specified to upload. I'm trying to solve this by having one INPUT TYPE=FILE box, and, using javascript, each time someone selects a file, it populates one listbox below it. Once the submit button is pressed, I'm sending the...
3
3465
by: Kim Lots | last post by:
Hi all I'm trying to pass two variables, but what is wrong with my code? -------- <form name="uno" action="validate.asp?Num=<%=Request.Querystring("Num") %>" method="post"> <textarea name="komm" cols="90" rows="4" id="komm"></textarea>
3
1572
by: Lee | last post by:
Hi All How can I pass options from one webpage into another webpage. When the user clicks on the hyperlink I want them to be go to the next page but I need to pass in a number that the next page needs to reference. Thanks Lee
2
1303
by: Thomas Beyerlein | last post by:
Hello, I am trying to build a UI and I need the user to go though about 4 forms making decisions and then passing the decision to the next form. Finally on the last form I need all the answers to open the next and final form, which there are 16 different ways to go. So I thought by putting the decisions in an array, and passing it to each form. I get this error-: Value of type '1-dimensional array of String' cannot be converted to...
13
2522
by: Deano | last post by:
Apparently you can only do this with one value i.e Call MyAssetLocationZoom(Me!txtLocation, "Amend data") This runs; Public Sub MyAssetLocationZoom(ctl As Control, formName As String) On Error GoTo err_zoom strFormName = formName
0
1544
by: Magnus Bergh | last post by:
I am developing an application for pocketpc and this involvs a but of juggling with different forms. I have an "order entry" type of application. On the main form I have a grid which displays Order headers. Let call this form "OrderList" From this view I edit/enter new orders by opening a new form for entering data. This is done using (more or less) the designer generated forms, so I have a "Order edit view dialog. I pass the binding...
6
1543
by: gggram2000 | last post by:
I'd like to know how I go about passing two variables from one form to the next. For example, I can pass a variable like this: This demonstrates how to pass a variable to a form when the form is opened. private void OpenForm_Click(object sender, System.EventArgs e) { // Get the value to be passed string parentValue = this.UserResponse.Text; // Create the child form and pass the value in the constructor
0
9647
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9489
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10357
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10162
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8988
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7509
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6744
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3665
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2893
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.