PC Review


Reply
 
 
wAyne
Guest
Posts: n/a
 
      1st Feb 2010
I'm trying to go through a table one record at a time.
here is my code

Dim str_sqltext As String
Dim con1 As DAO.Database
Dim rst_Estim As DAO.Recordset

str_sqltext = "SELECT Estim.PartNo, Estim.Desc, Estim.ProdCode " _
& "FROM Estim " _
& "WHERE Estim.ProdCode Like " & Chr(34) & "FG*" & Chr(34) _
& ";"


Set con1 = CurrentDb
Set rst_Estim = con1.OpenRecordset(str_sqltext)

If Not rst_Estim.EOF Then
rst_Estim.MoveFirst

Do While Not rst_Estim.EOF
str_PartNo = rst_Estim!PartNo
Call Materials_0_Detail

rst_Estim.MoveNext
Loop
Else
MsgBox "No Finished goods parts???"
End If


I swear I have done this before with no problems -- now I get the following
error:

Run Time Error 3061
Too Few parameters - expected 1

This happens on the Set rst_Estim = con1.OpenRecordset(str_sqltext) command.

The only thing I can think of that is different from other times I have done
this is the table "Estim" is a linked table.

thanks
for your help
wAyne
 
Reply With Quote
 
 
 
 
Douglas J. Steele
Guest
Posts: n/a
 
      1st Feb 2010
Make sure you haven't made a typo on any of the names in your Select query.

--
Doug Steele, Microsoft Access MVP
http://www.AccessMVP.com/DJSteele
(no e-mails, please!)

"wAyne" <(E-Mail Removed)> wrote in message
news06592AB-832B-437C-89F5-(E-Mail Removed)...
> I'm trying to go through a table one record at a time.
> here is my code
>
> Dim str_sqltext As String
> Dim con1 As DAO.Database
> Dim rst_Estim As DAO.Recordset
>
> str_sqltext = "SELECT Estim.PartNo, Estim.Desc, Estim.ProdCode " _
> & "FROM Estim " _
> & "WHERE Estim.ProdCode Like " & Chr(34) & "FG*" & Chr(34) _
> & ";"
>
>
> Set con1 = CurrentDb
> Set rst_Estim = con1.OpenRecordset(str_sqltext)
>
> If Not rst_Estim.EOF Then
> rst_Estim.MoveFirst
>
> Do While Not rst_Estim.EOF
> str_PartNo = rst_Estim!PartNo
> Call Materials_0_Detail
>
> rst_Estim.MoveNext
> Loop
> Else
> MsgBox "No Finished goods parts???"
> End If
>
>
> I swear I have done this before with no problems -- now I get the
> following
> error:
>
> Run Time Error 3061
> Too Few parameters - expected 1
>
> This happens on the Set rst_Estim = con1.OpenRecordset(str_sqltext)
> command.
>
> The only thing I can think of that is different from other times I have
> done
> this is the table "Estim" is a linked table.
>
> thanks
> for your help
> wAyne



 
Reply With Quote
 
DaveT
Guest
Posts: n/a
 
      2nd Feb 2010
One way to debug SQL statements in VBA is to use Debug.Print to print the SQL
generated from VBA. (In you case, after str_sqltext put a line with
Debug.Print str_sqltext).

If you know the procedure will crash for sure, go ahead and temporarily put
Exit Function (or Exit Sub) afte the Debug.Print line.

Call the procedure, then cut and paste the sql statement from the Immediate
window into a new SQL query using the query designer interface.

You can debug the sql statement there.


--
Dave Thompson
Allen, TX
US


"wAyne" wrote:

> I'm trying to go through a table one record at a time.
> here is my code
>
> Dim str_sqltext As String
> Dim con1 As DAO.Database
> Dim rst_Estim As DAO.Recordset
>
> str_sqltext = "SELECT Estim.PartNo, Estim.Desc, Estim.ProdCode " _
> & "FROM Estim " _
> & "WHERE Estim.ProdCode Like " & Chr(34) & "FG*" & Chr(34) _
> & ";"
>
>
> Set con1 = CurrentDb
> Set rst_Estim = con1.OpenRecordset(str_sqltext)
>
> If Not rst_Estim.EOF Then
> rst_Estim.MoveFirst
>
> Do While Not rst_Estim.EOF
> str_PartNo = rst_Estim!PartNo
> Call Materials_0_Detail
>
> rst_Estim.MoveNext
> Loop
> Else
> MsgBox "No Finished goods parts???"
> End If
>
>
> I swear I have done this before with no problems -- now I get the following
> error:
>
> Run Time Error 3061
> Too Few parameters - expected 1
>
> This happens on the Set rst_Estim = con1.OpenRecordset(str_sqltext) command.
>
> The only thing I can think of that is different from other times I have done
> this is the table "Estim" is a linked table.
>
> thanks
> for your help
> wAyne

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Outlook Create Message, Select To, Select Conacts- ...No Sort Opti Hyny Microsoft Outlook Contacts 1 9th Jul 2009 08:04 PM
Select report(s) to print via multi-select list box Access 2003 =?Utf-8?B?Z2FqbGowNw==?= Microsoft Access Getting Started 2 8th Nov 2007 02:53 AM
uninstalling client services for netwre to select to select logon and logoff opt Ahsan Windows XP New Users 4 31st May 2006 04:02 PM
SELECT INVALID SELECT STATEMENT TO FORCE ODBC DRIVER TO UNPREPARED STATE Jason Teng Microsoft Windows 2000 2 28th Oct 2003 06:03 PM
Outlook 2003 Email Select Names Type name or select from list nsnews.microsoft.com Microsoft Outlook 2 19th Oct 2003 06:22 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:43 PM.