473,385 Members | 1,597 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Run Time error 3061

Jon
Hello all:

I'm trying to modify an existing db for someone who wants to set
appointments in a customer db. They want to prevent someone from
double booking appts.

I've developed a few lines of code to do this, but I keep getting hung
on the SQL string. Here is the code:
------
Private Function CheckAppt(SALESMAN)
Dim oAppt
Dim strMsg

This line is the one that returns the 3061 error---->
Set oAppt = Application.CurrentDb.OpenRecordset("SELECT * FROM
[Lead-Appiontments] WHERE SALESMAN=" & SALESMAN)

If (APPT_DATE & APPT_TIME = LEAD - Appointments.APPT_DATE & LEAD -
Appointments.APPT_TIME) Then
strMsg = MsgBox("This Salesman already has a appointment set for
this date/time. Please choose another.", vbCritical, "Appointment
Scheduler")
End If

End Function
------------
The function is called from here:

Private Sub cboSalesman_LostFocus()
CheckAppt cboSalesman.Column(0, cboSalesman.Text)
End Sub
------------
The Select statement runs fine. I think the problem is in the WHERE
clause. WHen I try to debug, the SALESMAN clause receives the current
record name so I know that is working fine. Any clues?
Nov 13 '05 #1
2 1928
"Jon" <jf********@hotmail.com> wrote in message
news:17**************************@posting.google.c om...
Hello all:

I'm trying to modify an existing db for someone who wants to set
appointments in a customer db. They want to prevent someone from
double booking appts.

I've developed a few lines of code to do this, but I keep getting hung
on the SQL string. Here is the code:
------
Private Function CheckAppt(SALESMAN)
Dim oAppt
Dim strMsg

This line is the one that returns the 3061 error---->
Set oAppt = Application.CurrentDb.OpenRecordset("SELECT * FROM
[Lead-Appiontments] WHERE SALESMAN=" & SALESMAN)

If (APPT_DATE & APPT_TIME = LEAD - Appointments.APPT_DATE & LEAD -
Appointments.APPT_TIME) Then
strMsg = MsgBox("This Salesman already has a appointment set for
this date/time. Please choose another.", vbCritical, "Appointment
Scheduler")
End If

End Function
------------
The function is called from here:

Private Sub cboSalesman_LostFocus()
CheckAppt cboSalesman.Column(0, cboSalesman.Text)
End Sub
------------
The Select statement runs fine. I think the problem is in the WHERE
clause. WHen I try to debug, the SALESMAN clause receives the current
record name so I know that is working fine. Any clues?


If the argument SALESMAN is a string value then why not say so in your
function?
Private Function CheckAppt(strSalesman As String)

It is then clear you need some surrounding quotes:
strSQL = strSQL & " WHERE SALESMAN=""" & strSalesman & """"
Assuming that strSalesman could not itself contain quotes (you could check /
correct this)

And while you giving the argument a type, you could go wild and give your
function a return type, eg:
Private Function CheckAppt(strSalesman As String) As Boolean

But I still can't see it quite working well. Your current function seems to
open up a recordset based on every single record in the appointments table
for that salesman. Ignoring for the moment how you would actually implement
it, surely a better function might be:

Private Function IsHeBusy(strSalesman As String, dteDateTime As Date) As
Boolean


Nov 13 '05 #2
Jon wrote:
Hello all:

I'm trying to modify an existing db for someone who wants to set
appointments in a customer db. They want to prevent someone from
double booking appts.

I've developed a few lines of code to do this, but I keep getting hung
on the SQL string. Here is the code:
------
Private Function CheckAppt(SALESMAN)
Dim oAppt
Dim strMsg

This line is the one that returns the 3061 error---->
Set oAppt = Application.CurrentDb.OpenRecordset("SELECT * FROM
[Lead-Appiontments] WHERE SALESMAN=" & SALESMAN)


Assuming SALESMAN is a string (hint: naming conventions help around here
:-) then...

Set oAppt = Application.CurrentDb.OpenRecordset("SELECT * FROM
[Lead-Appiontments] WHERE SALESMAN='" & SALESMAN & "'")
--

\\\\\\
\\ \\ Windows is searching
\ \ For your sig.
\ \ Please Wait.
\__\

Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Miranda Evans | last post by:
I noticed several postings about issues related to "run-time error 3061", and I observed that the solutions to these issues appear to involve correcting something within the SQL code. I'm...
2
by: Steve Richfield | last post by:
There have been LOTS of postings about error 3061, but mine seems to be an even simpler case than the others. I have a simple **FUNCTIONING** query called qryEdits. Copying the SQL from the query,...
4
by: Richard Hollenbeck | last post by:
I thought I was very specific in this SQL request. There is a form open with a selected record (and a corresponding "lngRecipeID" on that form. The table also has a field called "lngRecipeID". ...
1
by: Richard Hollenbeck | last post by:
I wonder what I'm missing? I really feel like a retard because I've been screwing with some code for a very long time. I just must be missing something very simple. In the following example,...
1
by: istya | last post by:
I am having a dumb day to day. Can anyone have a schufty at my code and see why I am getting the runtime error 3061? I'm working on 2000 if that helps at all. Dim dbs As DAO.Database Dim...
3
by: ragtopcaddy via AccessMonster.com | last post by:
I have an error handler: On Error GoTo Outtahere At the end of the routine, the OuttaHere section reads: OuttaHere: If Err.Number <0 Then If Err.Number = 3061 Then Debug.Print " Failed to...
1
atksamy
by: atksamy | last post by:
i have the following code On Error GoTo TableTest_Error Set rs3 = CurrentDb.OpenRecordset(strsql3) GoTo continue ...
3
by: phill86 | last post by:
Hi, I am trying to run the following query in a recordset and i get the following error message Runtime error 3061 - Too few parameters. Expected 1 i am using the following code
8
Cintury
by: Cintury | last post by:
The problem is I have a function that I've created and stored in a module. I call it as an expression (e.g. total: Function(parameter)). I'm receiving the error 3061: too few parameters, expected 1....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.