Run-time error '3061': Too few parameters. Expected 1.

G

Gaetan

Hi,

I'm having a problem that's driving me nuts.

Run-time error '3061': Too few parameters. Expected 1.

I'm having a listing of Associates (employees) in a continuous form from
which I can select an item in a combo box. When this item is selected, a form
pops up. On this form (frmTransferAssociate), there's a cancel button that
the user can click to cancel the operation and it removes what was entered in
the first form's combo box, thus cancelling that it was ever selected.

I've created the following code to access the underlying recordset (a query
based on a table) so that I can erase the selected item from the associate's
record.

Private Sub cmdCancel_Click()

Dim db As DAO.Database
Dim rst As DAO.Recordset

Set db = CurrentDb
Set rst = db.OpenRecordset("qlkpCurrentWorkEntry")

rst.FindFirst ("AssociateID = " & Me.txtAssociateID)
If Not rst.NoMatch Then
rst.Edit
rst![DayStatusID] = Null
rst.Update
End If

rst.Close
Set rst = Nothing

End Sub

The qlkpCurrentWorkEntry query has the following fields:
WorkEntryID (criteria: Like [Forms]![frmTransferAssociate]![txtWorkEntry])
AssociateID
DayStatusID

All controls and fields seem to be spelled correctly.

Anyone can help?
 
D

Douglas J. Steele

Try:

Private Sub cmdCancel_Click()

Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim rst As DAO.Recordset
Dim parm As DAO.Parameter

Set db = CurrentDb

Set qdf = db.QueryDefs("qlkpCurrentWorkEntry")
For Each parm in qdf.Parameters
parm.Value = Eval(parm.Name)
Next Parm

Set rst = qdf.OpenRecordset

rst.FindFirst ("AssociateID = " & Me.txtAssociateID)
If Not rst.NoMatch Then
rst.Edit
rst![DayStatusID] = Null
rst.Update
End If

rst.Close
Set rst = Nothing

End Sub
 
G

Gaetan

I'm not getting the error message anymore but it doesn't clear the field like
it's supposed to.


Douglas J. Steele said:
Try:

Private Sub cmdCancel_Click()

Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim rst As DAO.Recordset
Dim parm As DAO.Parameter

Set db = CurrentDb

Set qdf = db.QueryDefs("qlkpCurrentWorkEntry")
For Each parm in qdf.Parameters
parm.Value = Eval(parm.Name)
Next Parm

Set rst = qdf.OpenRecordset

rst.FindFirst ("AssociateID = " & Me.txtAssociateID)
If Not rst.NoMatch Then
rst.Edit
rst![DayStatusID] = Null
rst.Update
End If

rst.Close
Set rst = Nothing

End Sub


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Gaetan said:
Hi,

I'm having a problem that's driving me nuts.

Run-time error '3061': Too few parameters. Expected 1.

I'm having a listing of Associates (employees) in a continuous form from
which I can select an item in a combo box. When this item is selected, a
form
pops up. On this form (frmTransferAssociate), there's a cancel button that
the user can click to cancel the operation and it removes what was entered
in
the first form's combo box, thus cancelling that it was ever selected.

I've created the following code to access the underlying recordset (a
query
based on a table) so that I can erase the selected item from the
associate's
record.

Private Sub cmdCancel_Click()

Dim db As DAO.Database
Dim rst As DAO.Recordset

Set db = CurrentDb
Set rst = db.OpenRecordset("qlkpCurrentWorkEntry")

rst.FindFirst ("AssociateID = " & Me.txtAssociateID)
If Not rst.NoMatch Then
rst.Edit
rst![DayStatusID] = Null
rst.Update
End If

rst.Close
Set rst = Nothing

End Sub

The qlkpCurrentWorkEntry query has the following fields:
WorkEntryID (criteria: Like [Forms]![frmTransferAssociate]![txtWorkEntry])
AssociateID
DayStatusID

All controls and fields seem to be spelled correctly.

Anyone can help?
 
D

Douglas J. Steele

You sure the code to set the field Null is actually being executed?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Gaetan said:
I'm not getting the error message anymore but it doesn't clear the field
like
it's supposed to.


Douglas J. Steele said:
Try:

Private Sub cmdCancel_Click()

Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim rst As DAO.Recordset
Dim parm As DAO.Parameter

Set db = CurrentDb

Set qdf = db.QueryDefs("qlkpCurrentWorkEntry")
For Each parm in qdf.Parameters
parm.Value = Eval(parm.Name)
Next Parm

Set rst = qdf.OpenRecordset

rst.FindFirst ("AssociateID = " & Me.txtAssociateID)
If Not rst.NoMatch Then
rst.Edit
rst![DayStatusID] = Null
rst.Update
End If

rst.Close
Set rst = Nothing

End Sub


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Gaetan said:
Hi,

I'm having a problem that's driving me nuts.

Run-time error '3061': Too few parameters. Expected 1.

I'm having a listing of Associates (employees) in a continuous form
from
which I can select an item in a combo box. When this item is selected,
a
form
pops up. On this form (frmTransferAssociate), there's a cancel button
that
the user can click to cancel the operation and it removes what was
entered
in
the first form's combo box, thus cancelling that it was ever selected.

I've created the following code to access the underlying recordset (a
query
based on a table) so that I can erase the selected item from the
associate's
record.

Private Sub cmdCancel_Click()

Dim db As DAO.Database
Dim rst As DAO.Recordset

Set db = CurrentDb
Set rst = db.OpenRecordset("qlkpCurrentWorkEntry")

rst.FindFirst ("AssociateID = " & Me.txtAssociateID)
If Not rst.NoMatch Then
rst.Edit
rst![DayStatusID] = Null
rst.Update
End If

rst.Close
Set rst = Nothing

End Sub

The qlkpCurrentWorkEntry query has the following fields:
WorkEntryID (criteria: Like
[Forms]![frmTransferAssociate]![txtWorkEntry])
AssociateID
DayStatusID

All controls and fields seem to be spelled correctly.

Anyone can help?
 
G

Gaetan

Alright... It is working. The problem was that it didn't find anything as the
record wasn't saved yet. So I added code to save the record before opening
frmTransferAssociate. When clicking Cancel, the code finds the record and
deletes the content of DayStatusID.

But because the combo box still contains the selected item value in the
form, I get a write conflict. How can I clear or undo the combo box which is
in a subform.

Main form: frmTLModule
Subform: fsubProduction
Combo box: cboStatus

Thanks.

Douglas J. Steele said:
You sure the code to set the field Null is actually being executed?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Gaetan said:
I'm not getting the error message anymore but it doesn't clear the field
like
it's supposed to.


Douglas J. Steele said:
Try:

Private Sub cmdCancel_Click()

Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim rst As DAO.Recordset
Dim parm As DAO.Parameter

Set db = CurrentDb

Set qdf = db.QueryDefs("qlkpCurrentWorkEntry")
For Each parm in qdf.Parameters
parm.Value = Eval(parm.Name)
Next Parm

Set rst = qdf.OpenRecordset

rst.FindFirst ("AssociateID = " & Me.txtAssociateID)
If Not rst.NoMatch Then
rst.Edit
rst![DayStatusID] = Null
rst.Update
End If

rst.Close
Set rst = Nothing

End Sub


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Hi,

I'm having a problem that's driving me nuts.

Run-time error '3061': Too few parameters. Expected 1.

I'm having a listing of Associates (employees) in a continuous form
from
which I can select an item in a combo box. When this item is selected,
a
form
pops up. On this form (frmTransferAssociate), there's a cancel button
that
the user can click to cancel the operation and it removes what was
entered
in
the first form's combo box, thus cancelling that it was ever selected.

I've created the following code to access the underlying recordset (a
query
based on a table) so that I can erase the selected item from the
associate's
record.

Private Sub cmdCancel_Click()

Dim db As DAO.Database
Dim rst As DAO.Recordset

Set db = CurrentDb
Set rst = db.OpenRecordset("qlkpCurrentWorkEntry")

rst.FindFirst ("AssociateID = " & Me.txtAssociateID)
If Not rst.NoMatch Then
rst.Edit
rst![DayStatusID] = Null
rst.Update
End If

rst.Close
Set rst = Nothing

End Sub

The qlkpCurrentWorkEntry query has the following fields:
WorkEntryID (criteria: Like
[Forms]![frmTransferAssociate]![txtWorkEntry])
AssociateID
DayStatusID

All controls and fields seem to be spelled correctly.

Anyone can help?
 
D

Douglas J. Steele

If the record isn't saved, why do you have to update anything? Simply use
Undo on the control.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Gaetan said:
Alright... It is working. The problem was that it didn't find anything as
the
record wasn't saved yet. So I added code to save the record before opening
frmTransferAssociate. When clicking Cancel, the code finds the record and
deletes the content of DayStatusID.

But because the combo box still contains the selected item value in the
form, I get a write conflict. How can I clear or undo the combo box which
is
in a subform.

Main form: frmTLModule
Subform: fsubProduction
Combo box: cboStatus

Thanks.

Douglas J. Steele said:
You sure the code to set the field Null is actually being executed?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Gaetan said:
I'm not getting the error message anymore but it doesn't clear the
field
like
it's supposed to.


:

Try:

Private Sub cmdCancel_Click()

Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim rst As DAO.Recordset
Dim parm As DAO.Parameter

Set db = CurrentDb

Set qdf = db.QueryDefs("qlkpCurrentWorkEntry")
For Each parm in qdf.Parameters
parm.Value = Eval(parm.Name)
Next Parm

Set rst = qdf.OpenRecordset

rst.FindFirst ("AssociateID = " & Me.txtAssociateID)
If Not rst.NoMatch Then
rst.Edit
rst![DayStatusID] = Null
rst.Update
End If

rst.Close
Set rst = Nothing

End Sub


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Hi,

I'm having a problem that's driving me nuts.

Run-time error '3061': Too few parameters. Expected 1.

I'm having a listing of Associates (employees) in a continuous form
from
which I can select an item in a combo box. When this item is
selected,
a
form
pops up. On this form (frmTransferAssociate), there's a cancel
button
that
the user can click to cancel the operation and it removes what was
entered
in
the first form's combo box, thus cancelling that it was ever
selected.

I've created the following code to access the underlying recordset
(a
query
based on a table) so that I can erase the selected item from the
associate's
record.

Private Sub cmdCancel_Click()

Dim db As DAO.Database
Dim rst As DAO.Recordset

Set db = CurrentDb
Set rst = db.OpenRecordset("qlkpCurrentWorkEntry")

rst.FindFirst ("AssociateID = " & Me.txtAssociateID)
If Not rst.NoMatch Then
rst.Edit
rst![DayStatusID] = Null
rst.Update
End If

rst.Close
Set rst = Nothing

End Sub

The qlkpCurrentWorkEntry query has the following fields:
WorkEntryID (criteria: Like
[Forms]![frmTransferAssociate]![txtWorkEntry])
AssociateID
DayStatusID

All controls and fields seem to be spelled correctly.

Anyone can help?
 
G

Gaetan

Thanks a lot for your help Douglas... I finally got it to work!

Douglas J. Steele said:
If the record isn't saved, why do you have to update anything? Simply use
Undo on the control.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Gaetan said:
Alright... It is working. The problem was that it didn't find anything as
the
record wasn't saved yet. So I added code to save the record before opening
frmTransferAssociate. When clicking Cancel, the code finds the record and
deletes the content of DayStatusID.

But because the combo box still contains the selected item value in the
form, I get a write conflict. How can I clear or undo the combo box which
is
in a subform.

Main form: frmTLModule
Subform: fsubProduction
Combo box: cboStatus

Thanks.

Douglas J. Steele said:
You sure the code to set the field Null is actually being executed?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


I'm not getting the error message anymore but it doesn't clear the
field
like
it's supposed to.


:

Try:

Private Sub cmdCancel_Click()

Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim rst As DAO.Recordset
Dim parm As DAO.Parameter

Set db = CurrentDb

Set qdf = db.QueryDefs("qlkpCurrentWorkEntry")
For Each parm in qdf.Parameters
parm.Value = Eval(parm.Name)
Next Parm

Set rst = qdf.OpenRecordset

rst.FindFirst ("AssociateID = " & Me.txtAssociateID)
If Not rst.NoMatch Then
rst.Edit
rst![DayStatusID] = Null
rst.Update
End If

rst.Close
Set rst = Nothing

End Sub


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Hi,

I'm having a problem that's driving me nuts.

Run-time error '3061': Too few parameters. Expected 1.

I'm having a listing of Associates (employees) in a continuous form
from
which I can select an item in a combo box. When this item is
selected,
a
form
pops up. On this form (frmTransferAssociate), there's a cancel
button
that
the user can click to cancel the operation and it removes what was
entered
in
the first form's combo box, thus cancelling that it was ever
selected.

I've created the following code to access the underlying recordset
(a
query
based on a table) so that I can erase the selected item from the
associate's
record.

Private Sub cmdCancel_Click()

Dim db As DAO.Database
Dim rst As DAO.Recordset

Set db = CurrentDb
Set rst = db.OpenRecordset("qlkpCurrentWorkEntry")

rst.FindFirst ("AssociateID = " & Me.txtAssociateID)
If Not rst.NoMatch Then
rst.Edit
rst![DayStatusID] = Null
rst.Update
End If

rst.Close
Set rst = Nothing

End Sub

The qlkpCurrentWorkEntry query has the following fields:
WorkEntryID (criteria: Like
[Forms]![frmTransferAssociate]![txtWorkEntry])
AssociateID
DayStatusID

All controls and fields seem to be spelled correctly.

Anyone can help?
 

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