C
Claire
Hi everyone-
I'm trying to automate with forms and am running into two problems I feel
like should be easy fixes, but are proving otherwise.
1) I have a button on a form that I would like to have open a second form
that you don't actually see, which in turn opens a third form that you do
see. (The second form runs a query off of information from the first form,
and fills the defaults for form three that is tied to a separate table.) I
tried opening the second form in Dialog Mode, and wanted to set its property
to invisible, but I can't find the code to do that. I'm looking for help
making the second form invisible when it's opened, or another solution to
this problem.
2) The third form of the chain has a button to cancel. When this is
clicked I would like the form to close and the data to NOT be entered (or to
be deleted) from the table. I've played around with various undo commands
and using DAO to see if a record exists, and though it can find a record and
delete it, this seems like it happens before the form is actually closed and
the record is added.
Thanks for any help you can offer!
~Claire
Code for 2), using DAO to delete the entry:
Private Sub Cancel_Click()
'Look if CS was created in table, if so, delete.
Dim db As DAO.Database
Dim rst As DAO.Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("Tests", dbOpenTable)
rst.Index = "PrimaryKey"
rst.Seek "=", Me.CS
DoCmd.Close
If Not rst.NoMatch Then
rst.Delete
MsgBox "found test and will delete it"
DoCmd.Close
Else
MsgBox "Didn't delete anything"
DoCmd.Close
End If
End Sub
I'm trying to automate with forms and am running into two problems I feel
like should be easy fixes, but are proving otherwise.
1) I have a button on a form that I would like to have open a second form
that you don't actually see, which in turn opens a third form that you do
see. (The second form runs a query off of information from the first form,
and fills the defaults for form three that is tied to a separate table.) I
tried opening the second form in Dialog Mode, and wanted to set its property
to invisible, but I can't find the code to do that. I'm looking for help
making the second form invisible when it's opened, or another solution to
this problem.
2) The third form of the chain has a button to cancel. When this is
clicked I would like the form to close and the data to NOT be entered (or to
be deleted) from the table. I've played around with various undo commands
and using DAO to see if a record exists, and though it can find a record and
delete it, this seems like it happens before the form is actually closed and
the record is added.
Thanks for any help you can offer!
~Claire
Code for 2), using DAO to delete the entry:
Private Sub Cancel_Click()
'Look if CS was created in table, if so, delete.
Dim db As DAO.Database
Dim rst As DAO.Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("Tests", dbOpenTable)
rst.Index = "PrimaryKey"
rst.Seek "=", Me.CS
DoCmd.Close
If Not rst.NoMatch Then
rst.Delete
MsgBox "found test and will delete it"
DoCmd.Close
Else
MsgBox "Didn't delete anything"
DoCmd.Close
End If
End Sub