My problem is two fold. First I am not very apt at VBA programming . Second, I have embarked on a project that is quickly getting out of control. I designed a database with one table to track items at work without knowing much about databases. It worked fine at first because I was the only one using it. But now everyone in the office is using it and I am running into all of the problems that are associated with poorly designed databases (having to add fields as requirements change, and user typos being the most annoying).
I am designing a new database with 15 new tables while everyone else in the office uses the old one.
My main stumbling block right now is described below.
I am using the following code to open a form that enters a new record on a cmd button on a subform.
Private Sub cmdPtasNew_Click()
On Error GoTo Err_cmdPtasNew_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmPtasNew"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord acDataForm, stDocName, acNewRec
Forms!frmPtasNew!ProcedureID = Forms![frmHostNationViewProcedure]![ProcedureID]
Exit_cmdPtasNew_Click:
Exit Sub
Err_cmdPtasNew_Click:
MsgBox Err.Description
Resume Exit_cmdPtasNew_Click
End Sub
This code works fine thanks to the help of Rich and others. But I have not been able to come up with the code to open a new form “frmPtasEdit” to edit the data in the current record.
The form to enter new data is called “frmPtasNew” this form opens with a new record for the same ProcedureID.
“frmPtasView” is a form used as a subform on the mainform.
frmHostNationViewProcedure is the main form
Is it possible to use this code (modified slightly of course) to open the same record that is on the subform? Is there a function to replace acNewRec that will open the current record?
I have tried a number of different things, but none have worked so far.
If I get this form/subform problem solved, I can use the technique on 5 or 6 different forms in the program.
Thanks in advance for any help, I’m sure I will be asking for a lot of help in the near future.
Mike H.
I am designing a new database with 15 new tables while everyone else in the office uses the old one.
My main stumbling block right now is described below.
I am using the following code to open a form that enters a new record on a cmd button on a subform.
Private Sub cmdPtasNew_Click()
On Error GoTo Err_cmdPtasNew_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmPtasNew"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord acDataForm, stDocName, acNewRec
Forms!frmPtasNew!ProcedureID = Forms![frmHostNationViewProcedure]![ProcedureID]
Exit_cmdPtasNew_Click:
Exit Sub
Err_cmdPtasNew_Click:
MsgBox Err.Description
Resume Exit_cmdPtasNew_Click
End Sub
This code works fine thanks to the help of Rich and others. But I have not been able to come up with the code to open a new form “frmPtasEdit” to edit the data in the current record.
The form to enter new data is called “frmPtasNew” this form opens with a new record for the same ProcedureID.
“frmPtasView” is a form used as a subform on the mainform.
frmHostNationViewProcedure is the main form
Is it possible to use this code (modified slightly of course) to open the same record that is on the subform? Is there a function to replace acNewRec that will open the current record?
I have tried a number of different things, but none have worked so far.
If I get this form/subform problem solved, I can use the technique on 5 or 6 different forms in the program.
Thanks in advance for any help, I’m sure I will be asking for a lot of help in the near future.
Mike H.