?
Solved

Update Query

Posted on 2012-08-13
8
Medium Priority
?
498 Views
Last Modified: 2012-08-19
HI

I am trying to write an update query so that I can update the same fields with the click of a button from a form.
Giving me a syntax error
Update SETTLEMENT Set SETTLEMENT.Meetings = Forms!SETTLEMENTQuery!Meetings WHERE SETTLEMENT.RepName = fOSUserName() And SETTLEMENT.SDate = Forms!SETTLEMENTQuery!SDate

Open in new window


Thanks
Su
0
Comment
Question by:surah79
8 Comments
 
LVL 12

Expert Comment

by:mlongoh
ID: 38290430
What's fOSUserName()?  A user defined function?
0
 

Author Comment

by:surah79
ID: 38290591
Yes it is a user defined function
0
 

Author Comment

by:surah79
ID: 38290700
HI guys
I have updated the query still below
strSQL = "UPDATE [SETTLEMENT] SET [Meetings]=" & Nz(Me.Meetings.Value, 0) & "WHERE [SDate] =" & Me.SDate.Value _
  And "[RepName]=" & Me.RepName.Value
  

Open in new window

Still giving the error "Type mismatch"

Thanks
0
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
LVL 2

Expert Comment

by:rajshekher
ID: 38290878
Hi,

Please check that all concatenated value should return string value.

If it is other then string, then type mismatch error will be coming.
0
 
LVL 36

Assisted Solution

by:ste5an
ste5an earned 2000 total points
ID: 38291050
When [SDate] is a Date/Time value, then you need to format the value as US Date/Time string. See Allen Browne's SQLDate() function. Also there is an error in the string building and line continuation. E.g.

strSQL = "UPDATE [SETTLEMENT] " & _
  "SET [Meetings] = " & Nz(Me.Meetings.Value, 0) & " " & _
  "WHERE [SDate] = " & SQLDate(Me.SDate.Value) & " " & _
  "AND [RepName] = '" & Me.RepName.Value & "';"

Open in new window

Take care of the spaces. Use
MsgBox strSql

Open in new window

to display the SQL statement. Copy it into a new empty query to test it.
0
 

Author Comment

by:surah79
ID: 38294143
Hi ste5an

There is a message syntax error coming

syntax error(missing operator) in query expression '[SDate] = AND [RepName] ='JameRo"

Thanks
0
 
LVL 36

Accepted Solution

by:
ste5an earned 2000 total points
ID: 38299370
Take a look at the content of Me.SDate.Value. This control should not be empty and thus not be NULL. Also it should contain a date/time value, not an arbitrary string.
0
 

Author Closing Comment

by:surah79
ID: 38310327
Thanks a lot for your help
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In today's business world, data is more important than ever for informing marketing campaigns. Accessing and using data, however, may not come naturally to some creative marketing professionals. Here are four tips for adapting to wield data for insi…
What we learned in Webroot's webinar on multi-vector protection.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question