prov something simple but not obvious...

M

Mark J Kubicki

I would think that this should be simple, and I'm sure it is.... and that I
MUST be missing "SOMETHING OBVIOUS" (any suggestions).
LINE 7 fails because of "too few arguments"

the project does contain the tables: FixtureTypesNoProject, with fields;
[type], [Manufacturer]..., and table ProjectnInfo with fields: [ProjectName]
;
(plz ignore the blatant typos, in the names, I inherited them -UGH!) ;
the code is entered behind a report with a field [type] in its detail
section ; [type] is reporting correctly.


1 Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
2 Dim dbs As Database
3 Dim rst As DAO.Recordset
4 Dim rst1 As DAO.Recordset
5 Dim strSQL As String
strSQL = "select * from " _
& "FixtureTypesNoProject where type = " _
& Me!Type
6 Set dbs = CurrentDb

7 Set rst = dbs.OpenRecordset(strSQL, dbOpenSnapshot) 'THIS IS THE LINE
THAT FAILS

8 Set rst1 = dbs.OpenRecordset("ProjectnInfo", dbOpenTable)

9 Me.Text54 = "test: " & Me.Type & " " & rst!Manufacturer & " " '&
rst1!ProjectName
10 End Sub



as always,
thanks in advance
mark
 
M

mark kubicki

thanks...


Allen Browne said:
What is the data type of your Type field?

If Text, you need extra quotes, like this:
strSQL = "SELECT FixtureTypesNoProject.* " & vbCrLf & _
"FROM FixtureTypesNoProject " & vbCrLf & _
"WHERE (FixtureTypesNoProject.[type] = """ & Me.[Type] & """);"
Debug.Print strSql

If it still fails, try dbOpenDynaset.

If it still fails, open the Immediate Window (Ctrl+G) and copy the SQL
statement that printed there into a query (SQL View), to see if you can
determine what is wrong.

For an explanation of the quotes, see:
http://allenbrowne.com/casu-17.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Mark J Kubicki said:
I would think that this should be simple, and I'm sure it is.... and that
I MUST be missing "SOMETHING OBVIOUS" (any suggestions).
LINE 7 fails because of "too few arguments"

the project does contain the tables: FixtureTypesNoProject, with fields;
[type], [Manufacturer]..., and table ProjectnInfo with fields:
[ProjectName] ;
(plz ignore the blatant typos, in the names, I inherited them -UGH!) ;
the code is entered behind a report with a field [type] in its detail
section ; [type] is reporting correctly.


1 Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
2 Dim dbs As Database
3 Dim rst As DAO.Recordset
4 Dim rst1 As DAO.Recordset
5 Dim strSQL As String
strSQL = "select * from " _
& "FixtureTypesNoProject where type = " _
& Me!Type
6 Set dbs = CurrentDb

7 Set rst = dbs.OpenRecordset(strSQL, dbOpenSnapshot) 'THIS IS THE
LINE THAT FAILS

8 Set rst1 = dbs.OpenRecordset("ProjectnInfo", dbOpenTable)

9 Me.Text54 = "test: " & Me.Type & " " & rst!Manufacturer & " " '&
rst1!ProjectName
10 End Sub
as always,
thanks in advance
mark
 
D

Douglas J. Steele

It should be pointed out that Allen's also put the field and control names
Type in square brackets.

This is because Type is a reserved word in Access, and you should always
avoid using reserved words for your own purposes. (ideally you should rename
the field and the control, but if you can't, or won't, the square brackets
are definitely a good idea).

Allen has a lot more information about this at
http://www.allenbrowne.com/AppIssueBadWord.html

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Allen Browne said:
What is the data type of your Type field?

If Text, you need extra quotes, like this:
strSQL = "SELECT FixtureTypesNoProject.* " & vbCrLf & _
"FROM FixtureTypesNoProject " & vbCrLf & _
"WHERE (FixtureTypesNoProject.[type] = """ & Me.[Type] & """);"
Debug.Print strSql

If it still fails, try dbOpenDynaset.

If it still fails, open the Immediate Window (Ctrl+G) and copy the SQL
statement that printed there into a query (SQL View), to see if you can
determine what is wrong.

For an explanation of the quotes, see:
http://allenbrowne.com/casu-17.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Mark J Kubicki said:
I would think that this should be simple, and I'm sure it is.... and that
I MUST be missing "SOMETHING OBVIOUS" (any suggestions).
LINE 7 fails because of "too few arguments"

the project does contain the tables: FixtureTypesNoProject, with fields;
[type], [Manufacturer]..., and table ProjectnInfo with fields:
[ProjectName] ;
(plz ignore the blatant typos, in the names, I inherited them -UGH!) ;
the code is entered behind a report with a field [type] in its detail
section ; [type] is reporting correctly.


1 Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
2 Dim dbs As Database
3 Dim rst As DAO.Recordset
4 Dim rst1 As DAO.Recordset
5 Dim strSQL As String
strSQL = "select * from " _
& "FixtureTypesNoProject where type = " _
& Me!Type
6 Set dbs = CurrentDb

7 Set rst = dbs.OpenRecordset(strSQL, dbOpenSnapshot) 'THIS IS THE
LINE THAT FAILS

8 Set rst1 = dbs.OpenRecordset("ProjectnInfo", dbOpenTable)

9 Me.Text54 = "test: " & Me.Type & " " & rst!Manufacturer & " " '&
rst1!ProjectName
10 End Sub
as always,
thanks in advance
mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top