What is wrong with this

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Option Compare Database
Option Explicit

Dim dbsBALLS As Database
Dim rstBALLS As Recordset
Dim intBALLS As Integer

Public Sub Command3_Click()
'On Error GoTo Err_Command3_Click

Dim stDocName As String
Dim stLinkCriteria As String
Dim Number1 As Integer
Dim Number2 As Integer
Dim Number3 As Integer
Dim Number4 As Integer
Dim Number5 As Integer

Number1 = 16
Number2 = 26
Number3 = 36
Number4 = 46
Number5 = 6
Debug.Print "No 1", Number1
Debug.Print "No 2", Number2
Debug.Print "No 3", Number3
Debug.Print "No 4", Number4
Debug.Print "No 5", Number5

Rem This code gets all power ball numbers FROM THE FILE
Set dbsBALLS = CurrentDb

'Here we get all the records then, cycle thru them to find the right bus

Set rstBALLS = dbsBALLS.OpenRecordset("select * " _
& " FROM [BALL COUNT]," _
& "WHERE [ball number] =" & Number1)

@@--Seems like the Number1 is not being fed the value here @@

If rstBALLS.EOF = True Then NO_More_Powerball_Nos

Debug.Print "We found Balls "
 
I quick glance shows an extra comma at the end of this line.
& " FROM [BALL COUNT]," _
I assume there is a bunch more code following what you presented to us.

You should also get in the habit of using
Dim dbsBALLS as DAO.Database
Dim rstBALLS As DAO.Recordset

Consider changing the name of Command3 to something that might make sense to
someone viewing your code window.

Why do you think "@@--Seems like the Number1 is not being fed the value here
@@"?

What is "NO_More_Powerball_Nos"?
 
Here is all the code to date, the form is a simple toggle button to executer
the code and when I hit it I get and erro message:

runtime error 3061
too few parameters, expected 1.

And this line gets lit up in yellow....

Seems to me Number1 does not get transplted to the value its set to !!


Set rstBALLS = dbsBALLS.OpenRecordset("select * " _
& " FROM [BALL COUNT] " _
& "WHERE [ball number] = Number1 ")

---------------------------------------------------------------------------------
Option Compare Database
Option Explicit

Dim dbsBALLS As DAO.Database
Dim rstBALLS As DAO.Recordset
Dim intBALLS As Integer

Private Sub Start_Button_Click()


'On Error GoTo Err_Start_button_Click

Dim stDocName As String
Dim stLinkCriteria As String
Dim Number1 As Integer
Dim Number2 As Integer
Dim Number3 As Integer
Dim Number4 As Integer
Dim Number5 As Integer

Number1 = 16
Number2 = 26
Number3 = 36
Number4 = 46
Number5 = 6
Debug.Print "No 1", Number1
Debug.Print "No 2", Number2
Debug.Print "No 3", Number3
Debug.Print "No 4", Number4
Debug.Print "No 5", Number5

Rem This code gets all power ball numbers FROM THE FILE
Set dbsBALLS = CurrentDb

'Here we get the records then, eq to the ball # , at this time add the
number if not founf

Set rstBALLS = dbsBALLS.OpenRecordset("select * " _
& " FROM [BALL COUNT] " _
& "WHERE [ball number] = Number1 ")

If rstBALLS.EOF = True Then NO_More_Powerball_Nos

Debug.Print "We found Balls "

Stop

End Sub

Public Sub NO_More_Powerball_Nos()
Debug.Print "No More Balls "
' Dim dbsBALLS As Database
'Dim rstBALLS As Recordset
'Set dbsBALLS = CurrentDb
' Set rstBALLS = dbsBALLS.OpenRecordset("select * " _
' & " FROM [BALL COUNT] ")
rstBALLS.AddNew
rstBALLS![ball number] = Number1
rstBALLS![number count] = rstBALLS![number count] + 1
rstBALLS.Update
rstBALLS.Close

Stop



Exit_Start_button_Click:
Exit Sub

Err_Start_button_Click:
MsgBox Err.Description
Resume Exit_Start_button_Click


do_1:

' This part we have not worked on as we cant get by the Start_button stuff

With rstBALLS

.Edit
' Add one to count
rstBALLS![number count] = rstBALLS![number count] + 1
.Update
.Close
End With
End Sub

------------------------------------------------------------------------------
--
Charlie


Duane Hookom said:
I quick glance shows an extra comma at the end of this line.
& " FROM [BALL COUNT]," _
I assume there is a bunch more code following what you presented to us.

You should also get in the habit of using
Dim dbsBALLS as DAO.Database
Dim rstBALLS As DAO.Recordset

Consider changing the name of Command3 to something that might make sense to
someone viewing your code window.

Why do you think "@@--Seems like the Number1 is not being fed the value here
@@"?

What is "NO_More_Powerball_Nos"?
--
Duane Hookom
MS Access MVP
--

Charlie said:
Option Compare Database
Option Explicit

Dim dbsBALLS As Database
Dim rstBALLS As Recordset
Dim intBALLS As Integer

Public Sub Command3_Click()
'On Error GoTo Err_Command3_Click

Dim stDocName As String
Dim stLinkCriteria As String
Dim Number1 As Integer
Dim Number2 As Integer
Dim Number3 As Integer
Dim Number4 As Integer
Dim Number5 As Integer

Number1 = 16
Number2 = 26
Number3 = 36
Number4 = 46
Number5 = 6
Debug.Print "No 1", Number1
Debug.Print "No 2", Number2
Debug.Print "No 3", Number3
Debug.Print "No 4", Number4
Debug.Print "No 5", Number5

Rem This code gets all power ball numbers FROM THE FILE
Set dbsBALLS = CurrentDb

'Here we get all the records then, cycle thru them to find the right bus

Set rstBALLS = dbsBALLS.OpenRecordset("select * " _
& " FROM [BALL COUNT]," _
& "WHERE [ball number] =" & Number1)

@@--Seems like the Number1 is not being fed the value here @@

If rstBALLS.EOF = True Then NO_More_Powerball_Nos

Debug.Print "We found Balls "
 
Here is all the code to date, the form is a simple toggle button to executer
the code and when I hit it I get and erro message:

runtime error 3061
too few parameters, expected 1.

And this line gets lit up in yellow....

Seems to me Number1 does not get transplted to the value its set to !!


Set rstBALLS = dbsBALLS.OpenRecordset("select * " _
& " FROM [BALL COUNT] " _
& "WHERE [ball number] = Number1 ")

That's because you're sending the query the *NAME* of the variable
rather than the *VALUE* of that variable.

Try

Set rstBALLS = dbsBALLS.OpenRecordset("select * " _
& " FROM [BALL COUNT] " _
& "WHERE [ball number] = " & Number1)


John W. Vinson[MVP]
 
Hi,

Thanks for the help, with your input and my persistance, I amanged to
get to and end. with this program. I'm not sure more my analogy of poert
balll numbers will work but its code now.





--
Charlie


John Vinson said:
Here is all the code to date, the form is a simple toggle button to executer
the code and when I hit it I get and erro message:

runtime error 3061
too few parameters, expected 1.

And this line gets lit up in yellow....

Seems to me Number1 does not get transplted to the value its set to !!


Set rstBALLS = dbsBALLS.OpenRecordset("select * " _
& " FROM [BALL COUNT] " _
& "WHERE [ball number] = Number1 ")

That's because you're sending the query the *NAME* of the variable
rather than the *VALUE* of that variable.

Try

Set rstBALLS = dbsBALLS.OpenRecordset("select * " _
& " FROM [BALL COUNT] " _
& "WHERE [ball number] = " & Number1)


John W. Vinson[MVP]
 
Back
Top