A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

subform's field and corresponding recordset out of sync?



 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old November 8th, 2004, 04:58 AM
AB
external usenet poster
 
Posts: n/a
Default subform's field and corresponding recordset out of sync?

Hello,

I'm sure this is due to ignorance on my part, but I'm trying to understand
how the fields in a form and a form's recordset are related.

I thought that the fields in a form, (i.e. 'ID'), correspond to the form's
recordset, (i.e. me.Recordset("ID")), but they go out of sync when I have a
subform and I create a new record in the subform:

The example I have for reproducing it involves:
- I create two tables Table1 and Table2.
- Table1 has a reference to Table2: 'Table2Ref'
- a form frmTable2 with all of Table2's fields
- a form frmTable1 with all of Table1's fields, and frmTable2 as a subform.

The out of sync behavior happens if:
- I select the subform, frmTable1
- create a new entry (hit the * button)
- add some data there
- select a field in the master form

At this point I check the recordset's id vs. the form id and they differ.
This contines to be different even if I click back and forth on the subform.

Is this the correct behavior? I would think that the two would stay in sync.

This behavior doesn't occur if, after editing the new subform, I click the
pencil icon to save the subform's record.

This makes sense to me, but it seems as if the subform is saved when you
click off of it. Normally when you edit a record the '' icon turns into a
pencil, and it is saved to the database when you click on it. For a subform
this icon changes back to the '' after you exit the subform, but it doesn't
seem like the subforms values are saved to the recordset.

The reason I'm doing this is that I'd like to allow a user to create and
change the record a form refers to by using a subform. I'm using the Enter
and Exit events to set and get the subforms record and:
- using the recordset's 'findfirst' method for setting it
- using the recordset's id (or form id) for getting the current value

This works fine for everything but record creation. and using the form's id
value works fine too. I just want to understand what is causing this, and
I'm worried about there being problems in the future.

Maybe my questions a
- Is this the best way to allow a user to create/change the record referred
to in a form?
- Can I/Should I have the subform record be 'saved' (if that is the cause of
this)? If so, how do I do this?

Thanks!

P.S. here is the code for the subform's exit event:
Private Sub Child6_Exit(Cancel As Integer)
Dim tmp, tmp2 As String
tmp = Me.Child6.Form.Recordset("id")
tmp2 = Me.Child6.Form.id

' this only pops up when a new record is created, but not saved in the
subform
' before leaving subform focus
If tmp2 tmp Then
MsgBox (tmp & " in recordset not equal to " & tmp2 & " in form.id ")
End If
End Sub


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:07 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.