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!
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)
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: - pax1 = Forms![frmPaxInfo2].tblPaxInfo_subform.Form!FirstName & " " & Forms![frmPaxInfo2].tblPaxInfo_subform.Form!LastName
-
DoCmd.GoToRecord acDataForm, "tblPaxInfo subform", acNext
-
pax2 = Forms![frmPaxInfo2].tblPaxInfo_subform.Form!FirstName & " " & Forms![frmPaxInfo2].tblPaxInfo_subform.Form!LastName
-
DoCmd.GoToRecord acDataForm, "tblPaxInfo subform", acNext
-
pax3 = Forms![frmPaxInfo2].tblPaxInfo_subform.Form!FirstName & " " & Forms![frmPaxInfo2].tblPaxInfo_subform.Form!LastName
-
DoCmd.GoToRecord acDataForm, "tblPaxInfo subform", acNext
-
pax4 = Forms![frmPaxInfo2].tblPaxInfo_subform.Form!FirstName & " " & Forms![frmPaxInfo2].tblPaxInfo_subform.Form!LastName
-
DoCmd.GoToRecord acDataForm, "tblPaxInfo subform", acNext
-
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?
OK this is where im at: - Private Sub PaymentButton_Click()
-
On Error GoTo Err_PaymentButton_Click
-
-
Dim stDocName As String
-
Dim stLinkCriteria As String
-
Dim pax1 As String
-
Dim pax2 As String
-
Dim pax3 As String
-
Dim pax4 As String
-
Dim pax5 As String
-
Dim rst As ADODB.Recordset
-
-
Set rst = New ADODB.Recordset
-
rst.Open "tblPaxInfo", CurrentProject.Connection
-
-
rst.Filter = "[GroupNumber]= '" & Me![GroupNumber] & "' AND [ResNumber]= '" & Me![Individual Res #] & "'"
-
-
pax1 = rst("FirstName") & " " & rst("LastName")
-
rst.MoveNext
-
If rst.EOF Then
-
GoTo Continue
-
Else
-
pax2 = rst("FirstName") & " " & rst("LastName")
-
End If
-
rst.MoveNext
-
-
If rst.EOF Then
-
GoTo Continue
-
Else
-
pax3 = rst("FirstName") & " " & rst("LastName")
-
End If
-
rst.MoveNext
-
-
If rst.EOF Then
-
GoTo Continue
-
Else
-
pax4 = rst("FirstName") & " " & rst("LastName")
-
End If
-
rst.MoveNext
-
-
If rst.EOF Then
-
GoTo Continue
-
Else
-
pax5 = rst("FirstName") & " " & rst("LastName")
-
End If
-
Continue:
-
-
stDocName = "frmPaymentsNEW"
-
-
stLinkCriteria = "[Individual Res #]=" & "'" & Me![Individual Res #] & "'"
-
DoCmd.OpenForm stDocName, , , stLinkCriteria
-
-
Forms![frmPaymentsNEW]![GroupNumber] = Forms![frmPaxInfo2]![GroupNumber]
-
Forms![frmPaymentsNEW]![GroupName] = Forms![frmPaxInfo2]![GroupName]
-
-
Forms![frmPaymentsNEW].tblPayments_subform.Form![PaxName] = pax1
-
DoCmd.GoToRecord acDataForm, "tblPayments_subform", acNewRec
-
Forms![frmPaymentsNEW].tblPayments_subform.Form![PaxName] = pax2
-
DoCmd.GoToRecord acDataForm, "tblPayments_subform", acNewRec
-
Forms![frmPaymentsNEW].tblPayments_subform.Form![PaxName] = pax3
-
DoCmd.GoToRecord acDataForm, "tblPayments_subform", acNewRec
-
Forms![frmPaymentsNEW].tblPayments_subform.Form![PaxName] = pax4
-
DoCmd.GoToRecord acDataForm, "tblPayments_subform", acNewRec
-
Forms![frmPaymentsNEW].tblPayments_subform.Form![PaxName] = pax5
-
-
Exit_PaymentButton_Click:
-
Exit Sub
-
-
Err_PaymentButton_Click:
-
MsgBox Err.Description
-
Resume Exit_PaymentButton_Click
-
-
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?
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)
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?
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)
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?
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)
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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...
|
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
|
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?
|
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...
| |
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...
|
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
|
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...
|
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...
|
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...
|
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,...
| |
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...
|
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,...
|
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();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
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...
| |