473,804 Members | 3,675 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

getting info from one subform to another

111 New Member
I have a form called frmPaxInfo, and on this form is a subform called subfrmPaxInfo. This subform (which is filtered by cabin) contains the passengers name along with all charges associated with each passenger. On the main form there is a button which opens another form for payments. On the payments form there is a subform that displays the passengers name, payments made, and the date the payment was made. The problem im having is that when i click on the payments button, i want the passengers names from the subform on frmPaxInfo to autopopulate into the subform on the payments form. I tried using a DLookup, but that only works for one record, and there can be up to 5 passengers (each having a different record). Any ideas? Please let me know if you need more info.

Thanks!
Oct 31 '07 #1
8 1780
nico5038
3,080 Recognized Expert Specialist
I guess you'll have to pass the Cabin to the subform to filter just for the people needed....

Nic;o)
Oct 31 '07 #2
Neekos
111 New Member
That wouldn't work in this situation, as the Payments subform is based off a different table, which would be basically data entry. The user would add the payments as they went along - so there is nothing to filter.

Since there is only 5 possible passengers, i tried to cycle through the subform and assign them to variables as so:

Expand|Select|Wrap|Line Numbers
  1. pax1 = Forms![frmPaxInfo2].tblPaxInfo_subform.Form!FirstName & " " & Forms![frmPaxInfo2].tblPaxInfo_subform.Form!LastName
  2.     DoCmd.GoToRecord acDataForm, "tblPaxInfo subform", acNext
  3.     pax2 = Forms![frmPaxInfo2].tblPaxInfo_subform.Form!FirstName & " " & Forms![frmPaxInfo2].tblPaxInfo_subform.Form!LastName
  4.     DoCmd.GoToRecord acDataForm, "tblPaxInfo subform", acNext
  5.     pax3 = Forms![frmPaxInfo2].tblPaxInfo_subform.Form!FirstName & " " & Forms![frmPaxInfo2].tblPaxInfo_subform.Form!LastName
  6.     DoCmd.GoToRecord acDataForm, "tblPaxInfo subform", acNext
  7.     pax4 = Forms![frmPaxInfo2].tblPaxInfo_subform.Form!FirstName & " " & Forms![frmPaxInfo2].tblPaxInfo_subform.Form!LastName
  8.     DoCmd.GoToRecord acDataForm, "tblPaxInfo subform", acNext
  9.     pax5 = Forms![frmPaxInfo2].tblPaxInfo_subform.Form!FirstName & " " & Forms![frmPaxInfo2].tblPaxInfo_subform.Form!LastName
but it tells me that "tblPaxInfo subform" isn't open (it is - on the current form). Is it not possible to reference subforms using this method?
Nov 1 '07 #3
Neekos
111 New Member
OK this is where im at:

Expand|Select|Wrap|Line Numbers
  1. Private Sub PaymentButton_Click()
  2. On Error GoTo Err_PaymentButton_Click
  3.  
  4.     Dim stDocName As String
  5.     Dim stLinkCriteria As String
  6.     Dim pax1 As String
  7.     Dim pax2 As String
  8.     Dim pax3 As String
  9.     Dim pax4 As String
  10.     Dim pax5 As String
  11.     Dim rst As ADODB.Recordset
  12.  
  13.     Set rst = New ADODB.Recordset
  14.     rst.Open "tblPaxInfo", CurrentProject.Connection
  15.  
  16.     rst.Filter = "[GroupNumber]= '" & Me![GroupNumber] & "' AND [ResNumber]= '" & Me![Individual Res #] & "'"
  17.  
  18.     pax1 = rst("FirstName") & " " & rst("LastName")
  19.     rst.MoveNext
  20.     If rst.EOF Then
  21.         GoTo Continue
  22.     Else
  23.         pax2 = rst("FirstName") & " " & rst("LastName")
  24.     End If
  25.     rst.MoveNext
  26.  
  27.     If rst.EOF Then
  28.         GoTo Continue
  29.     Else
  30.         pax3 = rst("FirstName") & " " & rst("LastName")
  31.     End If
  32.     rst.MoveNext
  33.  
  34.     If rst.EOF Then
  35.         GoTo Continue
  36.     Else
  37.         pax4 = rst("FirstName") & " " & rst("LastName")
  38.     End If
  39.     rst.MoveNext
  40.  
  41.     If rst.EOF Then
  42.         GoTo Continue
  43.     Else
  44.         pax5 = rst("FirstName") & " " & rst("LastName")
  45.     End If
  46. Continue:
  47.  
  48.     stDocName = "frmPaymentsNEW"
  49.  
  50.     stLinkCriteria = "[Individual Res #]=" & "'" & Me![Individual Res #] & "'"
  51.     DoCmd.OpenForm stDocName, , , stLinkCriteria
  52.  
  53.     Forms![frmPaymentsNEW]![GroupNumber] = Forms![frmPaxInfo2]![GroupNumber]
  54.     Forms![frmPaymentsNEW]![GroupName] = Forms![frmPaxInfo2]![GroupName]
  55.  
  56.     Forms![frmPaymentsNEW].tblPayments_subform.Form![PaxName] = pax1
  57.     DoCmd.GoToRecord acDataForm, "tblPayments_subform", acNewRec
  58.     Forms![frmPaymentsNEW].tblPayments_subform.Form![PaxName] = pax2
  59.     DoCmd.GoToRecord acDataForm, "tblPayments_subform", acNewRec
  60.     Forms![frmPaymentsNEW].tblPayments_subform.Form![PaxName] = pax3
  61.     DoCmd.GoToRecord acDataForm, "tblPayments_subform", acNewRec
  62.     Forms![frmPaymentsNEW].tblPayments_subform.Form![PaxName] = pax4
  63.     DoCmd.GoToRecord acDataForm, "tblPayments_subform", acNewRec
  64.     Forms![frmPaymentsNEW].tblPayments_subform.Form![PaxName] = pax5
  65.  
  66. Exit_PaymentButton_Click:
  67.     Exit Sub
  68.  
  69. Err_PaymentButton_Click:
  70.     MsgBox Err.Description
  71.     Resume Exit_PaymentButton_Click
  72.  
  73. End Sub
It gets to the bolded line and gets stuck. It puts the value for pax1 in, but I guess the DoCmd to go to a new record on the subform doesnt work (or at least the way i have it doesnt work). It tells me that "tblPayments_su bform" isn't open, but it is on the current form. How can i reference this subform to go to a new record on it?
Nov 1 '07 #4
nico5038
3,080 Recognized Expert Specialist
I'm really puzzled why you want to use this much code.
In general when you have a Cabin with a max of five passengers, there will be a record with CabinID and PassengerID.
Now you're having to record the payments, then the way would be to use this CabinID and PassengerID record to record the payments, thus an additional table with CabinID, PassengerID and PaymentID will be needed. This can be achieved by having a Mainform for the "CabinID and PassengerID" and a subform with the payment (or payments).
This Mainform for the "CabinID and PassengerID" can be filtered for just the CabinID, thus enabling the user to "walk through" all passengers of one Cabin.

One option is to insert a default payment row when the cabins are filled with passengers, but this isn't necessary. Using a Payment subform linked by the mainform by CabinID and PassengerID will cause Access to automatically fill these keyfields in a new record.

Getting the idea ?

Nic;o)
Nov 1 '07 #5
Neekos
111 New Member
im afraid im not getting it, and i apologize. I'm still fairly new to Access and don't totally understand it all yet. Sometimes i overthink things and make them harder than the really are, and thats probably what im doing here. Let's start from the beginning and ill give you the metadata for my tables and the concept of what im trying to accomplish.

The main form (frmPaxInfo) is based off a table (tblManifest) with the following metadata:

Field DataType
ID AutoNumber PK
GroupNumber Text
GroupName Text
IndividualRes# Text
CabinNumber Text
Category Text
CategoryNum Text
Dining Text
PhoneNum Text
Address Text
Address2 Text
City Text
State Text
ZIP Text
Email Text
Comments Text


This form has a subform based off tblPaxInfo with the following metadata:

Field DataType
ID AutoNum
GroupNumber Text PK
ResNumber Text
FirstName Text
LastName Text
DOB/Age Text
PastGuest# Text
Cznship Text
Grats Currency
Insurance Currency
CruiseRate Currency
PortCharges Currency
Taxes Currency
Air Currency
Other Currency


There is a button on the main form that opens up a new form called frmPayments. The metadata for this table (tblPayments) is:

Field DataType
GroupNumber Text PK
ResNumber Text
PaxName Text
Deposit1 Currency
Deposit1Date Date/Time
Deposit2 Currency
Deposit2Date Date/Time
TCAmount Currency
FinalPayment Currency
FinalDate Date/Time


I want the payments form to open so that all (up to 5) passengers will show on the same form, with columns for each deposit and such to be entered. tblPayments is empty at this point. When they click on the payment button, i would like the passengers names to autopopulate into the form the same way that they are on the tblPaxInfo_subf orm.

Can you help me from here?
Nov 1 '07 #6
nico5038
3,080 Recognized Expert Specialist
Hmm, I see the tables need some "normalization" .
For me I would have a tblPassengers, a tblFlights and a tblPayments.
The Passengers are scheduled in a flight in a relationtable tblPassengerFli ght.
The tblPayments is linked to the tblPassengerFli ght and will have to allow a passenger to have one or more payments for his/her flight.

You could read the article on normalization at:
http://www.thescripts.com/forum/thread585228.html

Keep in mind that a normalized database table structure will pay back in less coding and efforts down the road.
Just imagine in your tables that a customer needs three payments while you have two payment fields....

Nic;o)
Nov 1 '07 #7
Neekos
111 New Member
yes i have read about the normalization. The only reason i need 2 payment fields in that table is that it makes it easier to query by 1st, 2nd, or Final payments. There will never be any more than these, ever. If i only have one payment field there, it makes it impossible to query by the different types.

Can you try to help me with my payments form by using these tables?
Nov 2 '07 #8
nico5038
3,080 Recognized Expert Specialist
The First, Second and Final payment are no reason for having three currency fields.
When your customers have to pay in three times, then you're free to insert three rows in the payment table with the amount, a sequencenumber and the PaymentDate to indicate that the value has been payed.

With the present tables I see no need to have a tblPaxInfo and a tblPayments as both have the same PK field...

Nic;o)
Nov 2 '07 #9

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

Similar topics

0
1586
by: Josh C. | last post by:
Hello everyone. I'm a bit of an Access newbie, so please bear with me. Please go to http://www.dumoti.com/access/ to view the database - 536kb. I'll go straight into examples: In the form NIGO_ITEM, you'll notice a subform to the NIGO_REASONS table. It won't let any data be entered into this subform and it gives the error: You cannot add or change a record because a related record is required in table CUSTOMER_TABLE. (Error 3201) This...
4
2770
by: Alienz | last post by:
I have a subform where I have a subform with 20 options to select from. When I set the multiselect property to simple and select multiple options, nothing is stored. I have another table with fieldID and fieldtype and I would like for evertime something is selected in the listbox for a new entry to be created with that fieldtype for the corresponding fieldID which is linked to the main form. Basically, how do I get info from the listbox...
1
3734
by: xmp333 | last post by:
Hi, I have a form that is designed as a data sheet view. Attached to this is a subform with some VB code. When the user clicks on a row, the subform should pop up and run the VB code which accesses the record corresponding to the row clicked. To get this row, I tried using Me.Parent.Bookmark. Unfortunately, this gets the "Current Record" which is set via the navigation
1
1354
by: xmp333 | last post by:
Hi, I have a data sheet with a subform; each time the user clicks on the "+" to show the subform, I want some code to run. I tried attaching the code to a wide variety of events, but at best they only ran the first time the subform popped up. How can I get the desired behavior? Is there an event I missed or is it more complex?
2
1426
by: jballard | last post by:
Hello, I have a database set-up with a form and two subforms in it. I have one of the subforms (replacement parts) set-up where you can pick part numbers from a drop down box and also pick a description of the part from a drop down box. These are two separate fields. I want to be able to pick the part number and have it put in the description automatically or the other way around. Which ever would by easier? I have a table with just...
1
2701
by: kkrizl | last post by:
I have a form that displays general information about an alarm permit location. There's a subform that shows detailed information about burglar alarms that have gone off at the location. When a new alarm is entered on the subform, I want to print a report that shows the general information and the alarms that were entered. The record source for the form is the Mailing List table (key is Alarm #). The record source for the subform is the...
1
1609
by: sparks | last post by:
I have a form/table with an autoid it is linked to a table/form with and ID as a 1 to many. Under this form/table I need another table with many records for each on of the many in the previous table. form1 form2 form3 table1 table2 table3 autoid -1-------------@ ID -1-----------------@- ID2 of course it won't allow this so I put in a second ID
8
1965
by: Christina123 | last post by:
Currently working with Microsoft Office 2000 and whatever version of Access came with that. I am developing a database to track the comings and goings of shared tools. Everything works splendidly except I have printing issues, primarily I have no idea what I am doing. I have a form that contains the date and the info of the person doing the ordering as well as a subform that has the serial number of the part, the description and storage...
4
5797
by: mgstlucia | last post by:
I have a Form (frmsOrders) with a subform (frmOrdersDetails Subform). I am trying to automatically fill in the Item Description, Unit and Price when choosing the SKU# from a combobox. I have this working perfectly for the Customer and Address info in the main part of the form, but the same syntax does not work in the Subform. I have read the 'How to refer to items in Subform' article in the How To section and many posts on the subject. I...
0
9707
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
9585
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
10338
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...
1
10323
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6856
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();...
0
5525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5658
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4301
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2997
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.