IanOhlander
03-06-2002, 11:45 AM
Hi,
I checked they visible earlier pages looking for an answer, as well as four books I have in front of me. I am new Access and have made good headway, but have run into two problesm.
I have been creating a reservations db. I have two related tables, spaces and reservations, both with autonumber ids. The spaces table is related to the reservations table through the reservationID. I have a a parent form called AvailableSpaces, which has the reservationID, customerID and a combo box that selects the type of spaces the user wants. Then there is a subform that is linked to that combo box that displays all the available spaces of that type. The subform is setup so that when one of the spaces listed receives the focus, its spaceID is copied into a text box on the subform. All of that works fine. What I need to do is create a button that, when pressed, sets certain fields of the selected space record, specifically, the reservationID field held in the parent form, and the available field to false (so it doesn't show up in the available query the subform is based on.)
I was thinking along the lines of this:
Me![selectedID]![ReservationID] = Me![ReservationID]
except that the Me![selectedID] doesn't refer to the record in the space table. Neither does: [Table]![Spaces]!Me![SelectedID]. How can I get a reference to that record so as to access its ReservationID field? This has got to be pretty basic to db programming, yet I can't find the answer anywhere. I know FindRecord only seems to work on records the form is based on, and my action is being done in the parent, which isn't based on the spaces table.
I tried:
Dim db As Database
Dim rs As Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("Spaces")
With rs
.Seek (Me!selectedID)
![ReservationID] = Me![ReservationID]
![Available] = False
.Update
.Close
End With
inside an event method, and it still doesn't work.
I had initially tried using macros, but I kept getting errors with the setValue action in the macro. Specifically, I couldn't tell the computer to set the value of the reservationID field of the specific record referred to by the spaceID (mentioned above). In other words, I wanted to be able to retrieve from the selectedID textbox the spaceID of the space I want, access that record, set its reservationID number to that in the reservationID textbox of the form this is in, and set the Available field to "no". In using a macro, I tried using OpenTable, but it visibly opened that table, and I don't want that. So that is my first problem.
2nd: how can I set up a total that will go through all the rooms in a reservation and add up the expenses so that they'll go on a billing sheet- if they have 1 res, sum one charge, 5 res, sum of 5 charges.)
Can you do that with macros or a wizard? The totalling of the expense fields in all the Space records who have the same reservationID?
Thank you for any help you can give me. I am sorry if this has been beaten to death.
Ian Ohlander
I checked they visible earlier pages looking for an answer, as well as four books I have in front of me. I am new Access and have made good headway, but have run into two problesm.
I have been creating a reservations db. I have two related tables, spaces and reservations, both with autonumber ids. The spaces table is related to the reservations table through the reservationID. I have a a parent form called AvailableSpaces, which has the reservationID, customerID and a combo box that selects the type of spaces the user wants. Then there is a subform that is linked to that combo box that displays all the available spaces of that type. The subform is setup so that when one of the spaces listed receives the focus, its spaceID is copied into a text box on the subform. All of that works fine. What I need to do is create a button that, when pressed, sets certain fields of the selected space record, specifically, the reservationID field held in the parent form, and the available field to false (so it doesn't show up in the available query the subform is based on.)
I was thinking along the lines of this:
Me![selectedID]![ReservationID] = Me![ReservationID]
except that the Me![selectedID] doesn't refer to the record in the space table. Neither does: [Table]![Spaces]!Me![SelectedID]. How can I get a reference to that record so as to access its ReservationID field? This has got to be pretty basic to db programming, yet I can't find the answer anywhere. I know FindRecord only seems to work on records the form is based on, and my action is being done in the parent, which isn't based on the spaces table.
I tried:
Dim db As Database
Dim rs As Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("Spaces")
With rs
.Seek (Me!selectedID)
![ReservationID] = Me![ReservationID]
![Available] = False
.Update
.Close
End With
inside an event method, and it still doesn't work.
I had initially tried using macros, but I kept getting errors with the setValue action in the macro. Specifically, I couldn't tell the computer to set the value of the reservationID field of the specific record referred to by the spaceID (mentioned above). In other words, I wanted to be able to retrieve from the selectedID textbox the spaceID of the space I want, access that record, set its reservationID number to that in the reservationID textbox of the form this is in, and set the Available field to "no". In using a macro, I tried using OpenTable, but it visibly opened that table, and I don't want that. So that is my first problem.
2nd: how can I set up a total that will go through all the rooms in a reservation and add up the expenses so that they'll go on a billing sheet- if they have 1 res, sum one charge, 5 res, sum of 5 charges.)
Can you do that with macros or a wizard? The totalling of the expense fields in all the Space records who have the same reservationID?
Thank you for any help you can give me. I am sorry if this has been beaten to death.
Ian Ohlander