Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old January 13th, 2005, 09:23 AM
Authorized User
 
Join Date: Jan 2004
Location: , , .
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default Error in VB code

Hi

Can anyone help me. I keep getting a missing operator error witb the following query. I'm appending a record to a table. Ive basically copied the sql from query design but added a parameter.

Here's query - it's a long one

 db.Execute "INSERT INTO tblARCHIVE ( UserID, UpdateDate, Name, [Section], Room, DataPoint, ExtensionNo, IALSServerUserName, [Group], EmailAddress, ComputerWorkgroup, ComputerDescription, SHTageCPU, SHTagMonitor, SHTagMisc, ComputerType, IPAddress, NetworkCard, NetworkPrinter, Bios, Model, Memory, Processor, HardDisk, CPU, Monitor, Mouse, Keyboard, CDDrive, Other, Year2000Checks, EthernetAddress, MaintenanceHistory, SHPrinterTag, AllocationNo, Type, SerialNumber, SupportPack, Expires ) " & _
               "SELECT Users.UserID, Users.UpdateDate, Users.Name, Users.Section, Users.Room, Users.DataPoint, Users.ExtensionNo, Users.IALSServerUserName, UsersGroups.Group, Users.EmailAddress, Computers.ComputerWorkgroup, Computers.ComputerDescription, Computers.SHTageCPU, Computers.SHTagMonitor, Computers.SHTagMisc, Computers.ComputerType, Computers.IPAddress, Computers.NetworkCard, Computers.NetworkPrinter, Computers.Bios, Computers.Model, Computers.Memory, Computers.Processor, Computers.HardDisk, Computers.CPU, Computers.Monitor, Computers.Mouse, Computers.Keyboard, Computers.CDDrive, Computers.Other, Computers.Year2000Checks, Computers.EthernetAddress, Computers.MaintenanceHistory, Printers.SHPrinterTag, Printers.AllocationNo, Printers.Type, Printers.SerialNumber, Printers.SupportPack, Printers.Expires " & _
               "FROM (Users INNER JOIN (Computers INNER JOIN Printers ON Computers.ComputerName = Printers.ComputerName) ON Users.UserID = Computers.UserID) INNER JOIN UsersGroups ON Users.UserID = UsersGroups.UserID WHERE (((Users.Name)=" & strUsername & ")));"

Many thanks
  #2 (permalink)  
Old January 13th, 2005, 11:55 AM
Registered User
 
Join Date: Nov 2004
Location: , , USA.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try taking the semicolin out of the brakets and putting at the end.

 WAS (((Users.Name)=" & strUsername & ")));"
 IS (((Users.Name)=" & strUsername & ")))";



  #3 (permalink)  
Old January 13th, 2005, 04:01 PM
Friend of Wrox
Points: 4,007, Level: 26
Points: 4,007, Level: 26 Points: 4,007, Level: 26 Points: 4,007, Level: 26
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Lansing, Michigan, USA.
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Quote:
quote:Originally posted by gonderdonk
 Try taking the semicolin out of the brakets and putting at the end.
 No, that's not it. The semi-colon must be inside the quote. If strUserName is a string then you definitely need to do this:

BEFORE
INNER JOIN UsersGroups ON Users.UserID = UsersGroups.UserID WHERE (((Users.Name)=" & strUsername & ")));"

AFTER
INNER JOIN UsersGroups ON Users.UserID = UsersGroups.UserID WHERE (((Users.Name)='" & strUsername & "')));"

That is, you need single quotes surrounding strUserName.

Where else have you altered the SQL? That will be a good clue.


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
  #4 (permalink)  
Old January 14th, 2005, 01:04 PM
Authorized User
 
Join Date: Jan 2004
Location: , , .
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

Many thanks Greg. Solved the problem.

Lindsey


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I write this vb 6 code to work in vb 2008? sanderson Visual Basic 2008 Essentials 3 June 10th, 2008 01:46 PM
VB Error: Syntax Error or Access Violation codehappy VB How-To 7 October 3rd, 2007 05:41 PM
Urgent:hard disk serial code and vb code ivanlaw Pro VB 6 0 July 25th, 2007 04:05 AM
VB: .Exe file, serial code and activation code ivanlaw Pro VB 6 8 July 6th, 2007 05:44 AM
ASP.NET Using VB.NET Chapt 3 Code error? uh6uj All Other Wrox Books 1 February 26th, 2004 10:46 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.