G
Guest
Hello,
I have searched this site for a 2K solution but did not find one, so I am posting this to the community for assistance.
I have a cmdSSOpenRel button on frm_SystemSheet. I want the OnClick event to open the corresponding system record in tbl_Release/frm_Release. This I have accomplished, however what I also want to do is if there is no corresponding record in tbl_Release, to then ask the user if they wants to create the data for that particular system, and if so, open a blank frm_Release where they can enter the data for that corresponding system. (It is a one (SysID) to many (Rel_SysID) relationship.)
Below is the code I have, but I am getting an error for "Dim CurDB As Database". I do not understand enough to write it correctly. Can anyone help, please?
Private Sub cmdSSOpenRel_Click()
On Error GoTo Err_cmdSSOpenRel_Click
Dim stDocName As String
Dim stLinkCriteria As String
Dim rsRelease As Recordset
Dim CurDB As Database ' problem statement
' This section works fine
stDocName = "frm_Release"
stLinkCriteria = "[Rel_SysID]=" & Me![SysID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
' works fine until here
Exit_cmdSSOpenRel_Click:
Exit Sub
' Have not been able to see if the below code works
Err_cmdSSOpenRel_Click:
MsgBox "There is no release data for this system, would you like to add this information?", _
vbQuestion + vbYesNo, "New Release"
If vbNo = True Then
Resume Exit_cmdSSOpenRel_Click
Else
Set CurDB = CurrentDb
Set rsRelease = CurrentDb
With CurrentDb
'Add new release record'
.AddNew
!Release = NewData
.Update
End With
CurrentDb.Close
Set CurrentDb = Nothing
End If
End Sub
I have searched this site for a 2K solution but did not find one, so I am posting this to the community for assistance.
I have a cmdSSOpenRel button on frm_SystemSheet. I want the OnClick event to open the corresponding system record in tbl_Release/frm_Release. This I have accomplished, however what I also want to do is if there is no corresponding record in tbl_Release, to then ask the user if they wants to create the data for that particular system, and if so, open a blank frm_Release where they can enter the data for that corresponding system. (It is a one (SysID) to many (Rel_SysID) relationship.)
Below is the code I have, but I am getting an error for "Dim CurDB As Database". I do not understand enough to write it correctly. Can anyone help, please?
Private Sub cmdSSOpenRel_Click()
On Error GoTo Err_cmdSSOpenRel_Click
Dim stDocName As String
Dim stLinkCriteria As String
Dim rsRelease As Recordset
Dim CurDB As Database ' problem statement
' This section works fine
stDocName = "frm_Release"
stLinkCriteria = "[Rel_SysID]=" & Me![SysID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
' works fine until here
Exit_cmdSSOpenRel_Click:
Exit Sub
' Have not been able to see if the below code works
Err_cmdSSOpenRel_Click:
MsgBox "There is no release data for this system, would you like to add this information?", _
vbQuestion + vbYesNo, "New Release"
If vbNo = True Then
Resume Exit_cmdSSOpenRel_Click
Else
Set CurDB = CurrentDb
Set rsRelease = CurrentDb
With CurrentDb
'Add new release record'
.AddNew
!Release = NewData
.Update
End With
CurrentDb.Close
Set CurrentDb = Nothing
End If
End Sub