Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question about 2 subforms which share the same recordset

Status
Not open for further replies.

cwroblew

MIS
Jun 4, 2002
6
US
I have done a lot of searching and going around in circles and I still can't get things to work right.

I have a client form with a bunch of tabs. On one of the tabs I have two subforms, one of which is in single form mode, and the other is a datasheet of all records for a client. I don't want recordselectors on my forms at all. So for the tabs, I have buttons for New, Renew and Save.

I have set up so that when I click in the datasheet subform, that record shows up on the other single form.

I have the following event handlers for the buttons. I have left in the commented out circles I followed that didn't quite work the way I thought they might.

Private Sub New_Click()
DoCmd.GoToRecord , , acNewRec

Me.Status.Caption = "New"
Select = a legal select statement

Set db = CurrentDb()
Set rst = db.OpenRecordset(Select)

Me.ID = rst!MaxID + 1
Me.ClientID = Parent.ClientID
End Sub

Private Sub Renew_Click()
Dim db As DAO.Database
Dim rst As DAO.Recordset

Set rst = Me.RecordsetClone
rst.Bookmark = Me.Bookmark

DoCmd.GoToRecord , , acNewRec

Me.lblStatus.Caption = "Renew"

Me.ClientID = rst!ClientID
... Preset a lot of fields ...

Me.Term.SetFocus
'Application.RefreshDatabaseWindow
Me.Requery
'Parent![datasheet_subform].Requery
'Me.Refresh
End Sub

Private Sub Save_Click()
Me.lblStatus.Caption = ""
Me.ClientID = Parent.ClientID
'DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
'Me.Requery
'Parent![datasheet_subform].Requery
Me.Refresh
End Sub

Goals:

1. I need to be able to renew and place the single form view on the renewed record (hit "renew" button).
2. The user has to be able to save the record and have the latest record be displayed in the single form view.
3. I need to be able to create a new record, which will be saved using the save button (see #2).

I'm not sure if the save needs to work differently for the renewed record than the new record.

The problems I'm having is (and some of these are with circles I tried and got lost in and may not totally reflect what is in code).

1. I can renew and save the record, but I get placed on the first record.
2. I can renew and instead of editing the new record I end up in the first record.
3. I managed to not save the ClientID in the record so the record doesn't show up in the list.
4. One of the circles, I ended up with #error in almost every field when I clicked "Save" and no saved record.
5. Once in a while I lose the link between child and parent fields for the main/subform so the properties are blank.

Some of these problems are not as important as achieving my goals, but I wouldn't mind knowing what went wrong to get the problems.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top