VB Error (1 Viewer)

Lory

New member
Local time
Today, 08:31
Joined
Mar 18, 2003
Messages
7
I have the following code I'm trying to execute.

Private Sub cmdSave_Click()

Dim cnnLocal As New ADODB.Connection
Dim rstCurr As New ADODB.Recordset
Dim fldCurr As ADODB.Field
Dim strTest As String

strTest = "None"

Set cnnLocal = CurrentProject.Connection

If cboLocation = "Dallas" Then

rstCurr.Open "Select subdivision from tblDallasAcct where Builder = '" & txtbuilder & "'" & _
"and subdivsion = '" & txtSubdivision & "'", cnnLocal, adOpenKeyset, adLockPessimistic


With rstCurr
Do Until .EOF
For Each fldCurr In .Fields
strTest = fldCurr.Value
Next
.MoveNext
Loop
End With

If strTest = "None" Then
'DoCmd.SetWarnings False
DoCmd.OpenQuery "qappNewDalAcct"
'DoCmd.SetWarnings True
Else
MsgBox "Subdivion already in table"
End If

rstCurr.Close

End If

End Sub

At the rstCurr.Open sql stament it gives me the following error: No value given for one or more required parameters. I actually copied the majority fo this code from an earlier database that I created, then renamed everything appropriately, so I am at a loss as to what is wrong.

Lory
 

Robert Saye

Registered User.
Local time
Today, 09:31
Joined
Jun 19, 2000
Messages
49
SQL statement looks good

Hi Lory,

I copied this into a test db, and changed the table and fields to my name, and the sql statement worked fine. When it breaks like that and it asks you to debug it just say yes, and hover your mouse over the txtbuilder and txtSubdivision variables, and make sure that they actually have the correct data. Lastly is just make sure that your spelling is correct for your fields.
 

Lory

New member
Local time
Today, 08:31
Joined
Mar 18, 2003
Messages
7
thank you

I actually found my error last night. It helps if one spells the name of the fields correctly. I checked that yesterday before posting here, but when I looked at the printout of my code some time later at home...there it was plain as day!

Thank you for the suggestions anyways!
 

Users who are viewing this thread

Top Bottom