473,395 Members | 1,791 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,395 software developers and data experts.

Updating a table is driving me crazy...!!!

I have tried this code so many times, and it is frustrating me... I want to check if a record exist then just update a field, if it doesnt exist then Add 1st and then update.... the following code, seems to be close..but i am getting Error: Type mismatch at "[meeting date] = '#" & x & "#'".......pls advise!!

Dim x As Date
Dim qry As QueryDef
Dim sql As String
Dim sql1 As String
Dim sql2 As String
Dim sqlCom As String

Set qry = CurrentDb().QueryDefs("addtomeeting")
x = [Forms]![Meeting]![meetingDate]
qry.Parameters("Meeting") = x
sql = "UPDATE [Adding requests to meeting] SET [Adding requests to meeting].[date added] = Date(), [Adding requests to meeting].[Meeting Date] = [forms]![meeting]![meeting date] WHERE ((([Adding requests to meeting].[Add to meeting])=Yes));"

sql1 = "INSERT INTO Meeting ( [Meeting Date] )"

sql2 = "values(#" & x & "#);"
sqlCom = sql1 & sql2
Dim stDocName As String
Dim stLinkCriteria As String

If DCount("[meeting date]", "Meeting", "[meeting date] = '#" & x & "#'") > 0 Then


stDocName = "Switchboard"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.RunSQL (sql)
DoCmd.Close acForm, "Meeting"

Else
stDocName = "Switchboard"
MsgBox "entered2"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.RunSQL (sqlCom)
DoCmd.RunSQL (sql)
DoCmd.Close acForm, "Meeting"

End If

End Sub
Aug 31 '09 #1

✓ answered by ajalwaysus

before I look at this too deeply, I noticed immediately that you wrapped the date field in # (pound sign) but you also put it in single quotes, that is not right, it should be

Expand|Select|Wrap|Line Numbers
  1. "[meeting date] = #" & Date & "#"
  2.  
By putting single quotes around the value, you are passing the literal value with the pound signs to the date field, which will fail.

Let me know if I need to dig in more,
-AJ

2 1451
ajalwaysus
266 Expert 100+
before I look at this too deeply, I noticed immediately that you wrapped the date field in # (pound sign) but you also put it in single quotes, that is not right, it should be

Expand|Select|Wrap|Line Numbers
  1. "[meeting date] = #" & Date & "#"
  2.  
By putting single quotes around the value, you are passing the literal value with the pound signs to the date field, which will fail.

Let me know if I need to dig in more,
-AJ
Aug 31 '09 #2
You actually got it right.....thanks alot :)....I was about to lose hope......
Sep 1 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: dont bother | last post by:
This is really driving me crazy. I have a dictionary feature_vectors{}. I try to sort its keys using #apply sorting on feature_vectors sorted_feature_vector=feature_vectors.keys()...
0
by: Shapper | last post by:
Hello, I have this code in Global.asax: Sub Session_Start(Sender As Object, E As EventArgs) Dim cookie As HttpCookie = Request.Cookies("MyCookie") If Not cookie Is Nothing Then...
1
by: Miguel Dias Moura | last post by:
Hello, I have been trying, for days, to retrieve a control's ClientId in a javascript function. I am using a master page and this is why I need to retrieve the Control's ClientId. The control...
5
by: Pupeno | last post by:
Hello, I am experiencing a weird behavior that is driving me crazy. I have module called Sensors containing, among other things: class Manager: def getStatus(self): print "getStatus(self=%s)"...
11
by: designkitt | last post by:
Hello, I am having a problem aligning a cell in a table and have tried everything I can think of to correct this without any luck: It appears that the white area, which is an image in the background...
1
by: Beeker | last post by:
I have a table called 'RawData' that collects production data. We run a report on this data everyday to see the performance of each employee. I have another table called 'tblStandards' with...
3
by: rashpal.sidhu | last post by:
Please help, this problem is driving me crazy !! I am using metaphone to create phonetic keys. When i run the module stand-a-lone it works fine. I'm trying to create a runner for informix...
5
by: mark4asp | last post by:
Every time the function below is called I get the alert. So I put a deliberate error in there and I check the value of (reportType=='MANDATE') in Firebug, which is found to be true. But still the...
24
by: psycho007 | last post by:
I was wondering if somebody could help me. this is driving me crazy. I am trying to send an array from a mysql_fetch_assoc result from table total_orders to table orders_complete. I have the...
2
by: kheitmann | last post by:
OK, so I have a blog. I downloaded the "theme" from somewhere and have edited a few areas to suit my needs. There are different font themes within the page theme. Long story short, my "Text Posts"...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.