Linking forms

G

Guest

Hi I am new to Access.

I have a Single Form (frmAtt) that when I select a record I than can click
on a button to open another Continuous form (frmTrv) and it will select that
records information from frmAtt.

Example:

frmatt.xyz = A frmtrv.xyz = A
frmatt.zzz = B frmtrv.zzz = B

This part works fine...

But when I close frmtrv this is what happens:
frmtrv.xyz = A frmatt.xyz = someother record
frmtrv.zzz = B frmatt.zzz = B

THIS IS THE PROBLEM!

When I delete the record from frmtrv:
frmtrv.xyz = A frmatt.xyz = A
frmtrv.zzz = B frmatt.zzz = B

This works fine!

I want the frmtrv to close with the current record on the previous opened
form showing.

Here is the code behind the close button on the frmtrv:

Private Sub btnCloseForm_Click()
On Error GoTo Err_btnCloseForm_Click
If Len(Me.[Order_Num] & "") = 0 Then
MsgBox "Record has not been entered - No Order Number"
End If
DoCmd.Close
Exit_btnCloseForm_Click:
Exit Sub

Err_btnCloseForm_Click:
MsgBox Error$
Resume Exit_btnCloseForm_Click

End Sub


Here is the code on the delete button on the frmtrv (AND THIS WORKS FINE) I
just wanted to show you that this is working for when it closes it goes back
to the current previous record:

Private Sub btnDelete_Click()
On Error GoTo Err_btnDelete_Click
Dim dbs As Database
Dim myrs As Recordset

Set dbs = CurrentDb()

Set myrs = Me.RecordsetClone
If myrs.RecordCount > 0 Then
delRec = MsgBox("You are about to delete 1 record. " & Chr(13) &
Chr(10) & Chr(13) & Chr(10) & "If you click Yes, you won't be able to undo
this Delete Operation. " & Chr(13) & Chr(10) & "Delete Current Record?",
vbExclamation + vbYesNo, "Delete Record")
If delRec = 6 Then
xmeet_num = Me!MEET_NUM
xssn = Me!SSN
strSql = "delete * from tblTravel where meet_num = '" &
xmeet_num & "' and ssn = '" & xssn & "'"
dbs.Execute strSql

Forms!frmAttendanceMeeting!EST_TRVL = 500
Forms!frmAttendanceMeeting!ACT_TRVL = 0

End If
End If
DoCmd.Close
Exit_btnDelete_Click:
Exit Sub

Err_btnDelete_Click:
MsgBox Error$
Resume Exit_btnDelete_Click






Thank You For Any Help....!
 
J

Jeff Boyce

Have you considered keeping this all on one "form"?

If you create a main form that holds the "parent" information (?frmAtt), a
second form that holds the "child" information (?frmTrv), and then embed the
second form in the first as a subform, you can connect them so as to have
the subform display the main form's related records.

No need to pass data back/forth, open other forms, close other forms, etc.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
G

Guest

Hi and thank you for your help. I don't understand, do you mean to hide the
second form (frmTrv) and when the button is click on to show the form, then
when the user closes the second form it is hidden again? Please show me some
example's..

And again thank you for any help!



Jeff Boyce said:
Have you considered keeping this all on one "form"?

If you create a main form that holds the "parent" information (?frmAtt), a
second form that holds the "child" information (?frmTrv), and then embed the
second form in the first as a subform, you can connect them so as to have
the subform display the main form's related records.

No need to pass data back/forth, open other forms, close other forms, etc.

Regards

Jeff Boyce
Microsoft Office/Access MVP

Amour said:
Hi I am new to Access.

I have a Single Form (frmAtt) that when I select a record I than can click
on a button to open another Continuous form (frmTrv) and it will select
that
records information from frmAtt.

Example:

frmatt.xyz = A frmtrv.xyz = A
frmatt.zzz = B frmtrv.zzz = B

This part works fine...

But when I close frmtrv this is what happens:
frmtrv.xyz = A frmatt.xyz = someother record
frmtrv.zzz = B frmatt.zzz = B

THIS IS THE PROBLEM!

When I delete the record from frmtrv:
frmtrv.xyz = A frmatt.xyz = A
frmtrv.zzz = B frmatt.zzz = B

This works fine!

I want the frmtrv to close with the current record on the previous opened
form showing.

Here is the code behind the close button on the frmtrv:

Private Sub btnCloseForm_Click()
On Error GoTo Err_btnCloseForm_Click
If Len(Me.[Order_Num] & "") = 0 Then
MsgBox "Record has not been entered - No Order Number"
End If
DoCmd.Close
Exit_btnCloseForm_Click:
Exit Sub

Err_btnCloseForm_Click:
MsgBox Error$
Resume Exit_btnCloseForm_Click

End Sub


Here is the code on the delete button on the frmtrv (AND THIS WORKS FINE)
I
just wanted to show you that this is working for when it closes it goes
back
to the current previous record:

Private Sub btnDelete_Click()
On Error GoTo Err_btnDelete_Click
Dim dbs As Database
Dim myrs As Recordset

Set dbs = CurrentDb()

Set myrs = Me.RecordsetClone
If myrs.RecordCount > 0 Then
delRec = MsgBox("You are about to delete 1 record. " & Chr(13) &
Chr(10) & Chr(13) & Chr(10) & "If you click Yes, you won't be able to undo
this Delete Operation. " & Chr(13) & Chr(10) & "Delete Current Record?",
vbExclamation + vbYesNo, "Delete Record")
If delRec = 6 Then
xmeet_num = Me!MEET_NUM
xssn = Me!SSN
strSql = "delete * from tblTravel where meet_num = '" &
xmeet_num & "' and ssn = '" & xssn & "'"
dbs.Execute strSql

Forms!frmAttendanceMeeting!EST_TRVL = 500
Forms!frmAttendanceMeeting!ACT_TRVL = 0

End If
End If
DoCmd.Close
Exit_btnDelete_Click:
Exit Sub

Err_btnDelete_Click:
MsgBox Error$
Resume Exit_btnDelete_Click






Thank You For Any Help....!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

RecordsetClone 6
Message appears twice. 4
Delete a table using VBA 1

Top