473,783 Members | 2,350 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(SALES MAN)
Dim oAppt
Dim strMsg

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

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

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

Private Sub cboSalesman_Los tFocus()
CheckAppt cboSalesman.Col umn(0, cboSalesman.Tex t)
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 1939
"Jon" <jf********@hot mail.com> wrote in message
news:17******** *************** ***@posting.goo gle.com...
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(SALES MAN)
Dim oAppt
Dim strMsg

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

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

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

Private Sub cboSalesman_Los tFocus()
CheckAppt cboSalesman.Col umn(0, cboSalesman.Tex t)
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(strSa lesman 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(strSa lesman 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(strSal esman 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(SALES MAN)
Dim oAppt
Dim strMsg

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


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

Set oAppt = Application.Cur rentDb.OpenReco rdset("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
3317
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 encountering the "run-time error 3061" issue, but I'm not sure how to go about correcting the SQL. My hunch is that I have not properly constructed things to identify a date field, but I don't know how to correct this issue. In addition to not...
2
5547
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, it reads: SELECT Edits.Pattern, Edits.From, Edits.To FROM Edits WHERE (((Edits.Language)=!.)); The idea is to select just the language-appropriate records from the
4
7165
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". But I keep getting this error: Runtime Error 3061: Too Few Parameters expected 1. What should I be looking for to fix this? Here's my code so far: Private Sub cmdAddIngredientToRecipe_Click() Dim dbGetRecipeID As DAO.Database
1
22307
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, I've stripped away everything that doesn't cause the error to make my question a little simpler. Here's the problem in its simplest form inside a report: Dim db As DAO.Database
1
1892
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 results As DAO.Recordset Set dbs = CurrentDb Set results = dbs.OpenRecordset("SELECT COUNT(*) FROM name_check;") MsgBox (results(0)) 'Set results = dbs.OpenRecordset("SELECT division FROM divisions WHERE station= """ + !! + """;")...
3
2550
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 get " & strFileName & " data" Err.Clear GoTo NextFile 'most likely, the spreadsheet lacks the lowUtilizationANDMemory field
1
1518
atksamy
by: atksamy | last post by:
i have the following code On Error GoTo TableTest_Error Set rs3 = CurrentDb.OpenRecordset(strsql3) GoTo continue TableTest_Error:
3
4387
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
2995
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. Now the query and database are already open so I'm not entirely sure of any connection strings I may need. I think part of the problem may be that the parameter I am using to call the function is part of the query. I am not sure how to come by this...
0
9643
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10313
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2875
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.