J
Jason
I'm trying to use the OpenRecordset method to autofill
some fields in a form. Below is the code I have. When I
open the form, I get the error
"Run-time error '3061':
Too few parameters. Expected 1."
Any idea what I'm doing wrong?
Thanks in advance for your help!
Jason
Private Sub Form_Current()
'If there is no entry in the e-mail field then fill it in
from previous entry
If IsNull(Me.E_mail) And IsNull(Me.Phone) And IsNull
(Me.Contact) Then
Dim rst As Recordset, dbs As Database, strSQL As
String
Set dbs = CurrentDb()
strSQL = "SELECT [1-1tblCAR].Contact, [1-
1tblCAR].Phone, [1-1tblCAR].[E-mail] " & _
"FROM [1-1tblCAR] INNER JOIN tblNCMT ON [1-
1tblCAR].NCMTNumber = tblNCMT.intNCMTNumber " & _
"WHERE (((tblNCMT.intVendorNumber)=[Forms]!
[1-1frmCAR]![frmNCMTsub].[Form]![intVendorNumber]));"
Set rst = dbs.OpenRecordset(strSQL)
rstOutput.Field(0) = Me.Contact
rstOutput.Field(1) = Me.Phone
rstOutput.Field(2) = Me.E_mail
'If there is no previous e-mail entered then look in
tblVendorsToReport
rst.MoveLast
Dim intCount As Integer
intCount = rst.RecordCount
If intCount < 1 Then
strSQL = "SELECT
tblVendorsToReport.SupplierEmail " & _
"FROM tblVendorsToReport INNER JOIN
tblNCMT ON tblVendorsToReport.VendNum =
tblNCMT.intVendorNumber " & _
"WHERE (((tblNCMT.intVendorNumber)=
[Forms]![1-1frmCAR]![frmNCMTsub].[Form]!
[intVendorNumber]));"
Set rst = dbs.OpenRecordset(strSQL)
rstOutput.Field(0) = Me.E_mail
End If
rst.Close
Set dbs = Nothing
End If
End Sub
some fields in a form. Below is the code I have. When I
open the form, I get the error
"Run-time error '3061':
Too few parameters. Expected 1."
Any idea what I'm doing wrong?
Thanks in advance for your help!
Jason
Private Sub Form_Current()
'If there is no entry in the e-mail field then fill it in
from previous entry
If IsNull(Me.E_mail) And IsNull(Me.Phone) And IsNull
(Me.Contact) Then
Dim rst As Recordset, dbs As Database, strSQL As
String
Set dbs = CurrentDb()
strSQL = "SELECT [1-1tblCAR].Contact, [1-
1tblCAR].Phone, [1-1tblCAR].[E-mail] " & _
"FROM [1-1tblCAR] INNER JOIN tblNCMT ON [1-
1tblCAR].NCMTNumber = tblNCMT.intNCMTNumber " & _
"WHERE (((tblNCMT.intVendorNumber)=[Forms]!
[1-1frmCAR]![frmNCMTsub].[Form]![intVendorNumber]));"
Set rst = dbs.OpenRecordset(strSQL)
rstOutput.Field(0) = Me.Contact
rstOutput.Field(1) = Me.Phone
rstOutput.Field(2) = Me.E_mail
'If there is no previous e-mail entered then look in
tblVendorsToReport
rst.MoveLast
Dim intCount As Integer
intCount = rst.RecordCount
If intCount < 1 Then
strSQL = "SELECT
tblVendorsToReport.SupplierEmail " & _
"FROM tblVendorsToReport INNER JOIN
tblNCMT ON tblVendorsToReport.VendNum =
tblNCMT.intVendorNumber " & _
"WHERE (((tblNCMT.intVendorNumber)=
[Forms]![1-1frmCAR]![frmNCMTsub].[Form]!
[intVendorNumber]));"
Set rst = dbs.OpenRecordset(strSQL)
rstOutput.Field(0) = Me.E_mail
End If
rst.Close
Set dbs = Nothing
End If
End Sub