A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

write sql using a form



 
 
Thread Tools Display Modes
  #1  
Old October 5th, 2004, 08:57 PM
Randal
external usenet poster
 
Posts: n/a
Default write sql using a form

I have several fields that I need to concatenate together based on user
selection in a form. For example, if the user selects Field1 then Field2, I
need a query with

SELECT [Table1]![Field1] & [Table1]![Field2].

If the user selects Field2 then Field1, I need a query with
SELECT [Table1]![Field2] & [Table1]![Field1]

Any help is appreciated.


  #2  
Old October 6th, 2004, 11:14 AM
Michel Walsh
external usenet poster
 
Posts: n/a
Default

Hi,


Start with an empty string (zero character) , then add the "fields" as
they are selected (gotFocus):

If SelectionInProgress Then
myString= myString & "FieldName" & ", "
End If


with SelectionInProgress a form-variable, Boolean, that you set to true when
your selection process is active.


At the end, remove the ending ", " and complete the SQL statement:

mySQL = "SELECT " & Left(myString, len(myString)-2) & " FROM
tableName"




Hoping it may help,
Vanderghast, Access MVP


"Randal" rlwnrAThighstream.net wrote in message
...
I have several fields that I need to concatenate together based on user
selection in a form. For example, if the user selects Field1 then Field2,
I
need a query with

SELECT [Table1]![Field1] & [Table1]![Field2].

If the user selects Field2 then Field1, I need a query with
SELECT [Table1]![Field2] & [Table1]![Field1]

Any help is appreciated.




 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Strange stLinkCriteria behaviour on command button Anthony Dowd Using Forms 3 August 21st, 2004 03:01 AM
Write Conflict Message when using a Form Danny Using Forms 1 July 24th, 2004 11:38 PM
Function isn't available in expressions in query expression Reiner Harmgardt General Discussion 4 July 21st, 2004 09:30 AM
Display Parameter from Form on Report sara Setting Up & Running Reports 10 July 19th, 2004 04:54 PM
Passing value to modal child form in MS Access using VBA? Grahammer Using Forms 6 July 4th, 2004 11:53 PM


All times are GMT +1. The time now is 02:35 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.