D
Dan @BCBS
My goal is to link two forms with a command button and learn how to define a
type.
Could you please help me define two new types (Database and Recordset)
This is my code.
Sub cmdProv_Click()
On Error GoTo Err_cmdProv_Click
Dim stDocName As String
Dim stLinkCriteria As String
Dim dbcurrent As Database
Dim rstemp As Recordset
If IsNull([ICNNO]) Then
MsgBox "Please enter the ICNSR # before proceeding."
Exit Sub
Else
'Check to see if a record already exists
Set dbcurrent = CurrentDb
Set rstemp = CurrentDb.OpenRecordset("select * from [t_PROV] where
[ICNSR] = " & "'" & Me.[ICNSR] & "'" & ";")
stDocName = "f_PROV"
If rstemp.RecordCount > 0 Then 'Open Record
stLinkCriteria = "[icnsr]=" & "'" & Me.[ICNSR] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else 'Create a new record
DoCmd.OpenForm stDocName, , , stLinkCriteria
Forms!f_PROV.DataEntry = True
End If
Forms!f_PROV.ICNNO = Me.ICNSR
End If
type.
Could you please help me define two new types (Database and Recordset)
This is my code.
Sub cmdProv_Click()
On Error GoTo Err_cmdProv_Click
Dim stDocName As String
Dim stLinkCriteria As String
Dim dbcurrent As Database
Dim rstemp As Recordset
If IsNull([ICNNO]) Then
MsgBox "Please enter the ICNSR # before proceeding."
Exit Sub
Else
'Check to see if a record already exists
Set dbcurrent = CurrentDb
Set rstemp = CurrentDb.OpenRecordset("select * from [t_PROV] where
[ICNSR] = " & "'" & Me.[ICNSR] & "'" & ";")
stDocName = "f_PROV"
If rstemp.RecordCount > 0 Then 'Open Record
stLinkCriteria = "[icnsr]=" & "'" & Me.[ICNSR] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else 'Create a new record
DoCmd.OpenForm stDocName, , , stLinkCriteria
Forms!f_PROV.DataEntry = True
End If
Forms!f_PROV.ICNNO = Me.ICNSR
End If