INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

malformed GUID in query expression

malformed GUID in query expression

(OP)
Not sure what I am doing wrong here...

The following code gives a malformed GUID in query expression message:

CODE -->

Set rs = CurrentDb.OpenRecordset(strSql, dbOpenDynaset)     
    strSql = "Select * from PC_SP_Line_tbl order by SP,[Line Number]" 

But have no problems when I place this in a query SQL as:

CODE -->

Select * from PC_SP_Line_tbl order by SP,[Line Number] 

What am I doing wrong?

Thanks

RE: malformed GUID in query expression

Are you setting the value of strSQL after you set rs as your code suggests?

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016

RE: malformed GUID in query expression

(OP)
Thanks Duane-

I am not setting the value of strSQL after I set rs...

I was playing around with this and noticed that if I change the code from

CODE -->

Select * from PC_SP_Line_tbl order by SP,[Line Number] 


to

CODE -->

Select * from PC_SP_Line_tbl order by SP" 


then I no longer get the error message, but I want this to be sorted by SP and then Line Number....

So then, I replaced [Line Number] with 'Line Number and this does not give an error message but this is not sorting the table by the fields SP and Line Number like a query does.

The Query with this SQL:


CODE -->

SELECT *
FROM PC_SP_Line_tbl
ORDER BY SP, [Line Number]; 

Creates this sorted order:

PC	SP	Qty	MySum	PreUsed	Line Number
019933		8	8		5
019933		4	3		6
019935		4	3		20
019933		8	7		27
019935		2	1		35
	008117	-6	8		27
	008117	8	8		3 
1

But after the following lines of code:

CODE -->

strSql = "Select * from SameOrd_tbl order by SPNote"
    Set rs = CurrentDb.OpenRecordset(strSql, dbOpenDynaset)     '  --- match up records that do not share ine numbers
    strSql = "Select * from PC_SP_Line_tbl order by SP, 'Line Number'"
    Set rsx = CurrentDb.OpenRecordset(strSql, dbOpenDynaset)
    If rs.RecordCount > 0 Then      ' if this is an empty table then don't bother...
       If rsx.RecordCount > 0 Then      ' if this is an empty table then don't bother...
          rs.MoveFirst
          Do While Not rs.EOF
             rsx.MoveFirst
             Do While Not rsx.EOF 

the Line Number of the record after the rsx.MoveFirst is Line "6" instead of '5"

Something is not right with this...


thanks

RE: malformed GUID in query expression

You have a table SameOrd_tbl, and another table PC_SP_Line_tbl, and looks like you want to "match up records that do not share line numbers" and 'do something' with/to those records.. You want to "match up records" on what field?

Looks to me that you do not need 2 record sets, you just need one record set with those 2 tables joined.

Have fun.

---- Andy

There is a great need for a sarcasm font.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close