Welcome to the { mindfrost82.com } forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

Go Back   { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Microsoft > MS Office > Access

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-25-2008, 10:00 AM
=?Utf-8?B?QmVocm9veiBaYW1pcmlhbg==?=
 
Posts: n/a
Query without field name

Hi;
Column name in A table that I import be changed periodically. Therfore, I
must change my query design.
How I can write a select statment only with column no. in design list of a
table.
(for exp. a statment like this: "Select Column[1], Column[3] from myTable")
Reply With Quote
  #2 (permalink)  
Old 08-25-2008, 10:38 AM
Stefan Hoffmann
 
Posts: n/a
Re: Query without field name

hi,

Behrooz Zamirian wrote:
> Column name in A table that I import be changed periodically. Therfore, I
> must change my query design.
> How I can write a select statment only with column no. in design list of a
> table.
> (for exp. a statment like this: "Select Column[1], Column[3] from myTable")

Use a query (:) to "normalize" your column names... You may use a
procedure for that.


mfG
--> stefan <--
Reply With Quote
  #3 (permalink)  
Old 08-25-2008, 12:46 PM
=?Utf-8?B?V2F5bmUtSS1N?=
 
Posts: n/a
Re: Query without field name

To follow on from Stefan's answer

If you have a number field in a table and there are used as the base for
controls on a form (for example) you can use ":" to alter the name

So - you import 3 fields into a table (called for example field1 2 and 3)
You have controls on a form that are sourced on fields called "AName",
"SomeOtherName" and "AndAnotherName"

You would use this to "alter" the name so your form/report/etc can use it

SELECT TableName.Field1 AS AName, TableName.Field2 AS SomeOtherName,
TableName.Field3 AS AndAnotherName
FROM TableName;

This would alter the field name in the table but just allow it to be used by
the other "bits" of your application.

Hope this helps

--
Wayne
Manchester, England.



"Stefan Hoffmann" wrote:

> hi,
>
> Behrooz Zamirian wrote:
> > Column name in A table that I import be changed periodically. Therfore, I
> > must change my query design.
> > How I can write a select statment only with column no. in design list of a
> > table.
> > (for exp. a statment like this: "Select Column[1], Column[3] from myTable")

> Use a query (:) to "normalize" your column names... You may use a
> procedure for that.
>
>
> mfG
> --> stefan <--
>

Reply With Quote
  #4 (permalink)  
Old 08-25-2008, 12:50 PM
=?Utf-8?B?V2F5bmUtSS1N?=
 
Posts: n/a
Re: Query without field name

SDoory clicked send before I should have.,

The next step - if you want - is to use a Make Table query.

This will create a new table with the new names - but there are not many
times when you would need this if your DB was set up right.

Of course this will create a table with the wrong name so you would need to
run a delete query before



Hope this helps

--
Wayne
Manchester, England.



"Stefan Hoffmann" wrote:

> hi,
>
> Behrooz Zamirian wrote:
> > Column name in A table that I import be changed periodically. Therfore, I
> > must change my query design.
> > How I can write a select statment only with column no. in design list of a
> > table.
> > (for exp. a statment like this: "Select Column[1], Column[3] from myTable")

> Use a query (:) to "normalize" your column names... You may use a
> procedure for that.
>
>
> mfG
> --> stefan <--
>

Reply With Quote
  #5 (permalink)  
Old 08-25-2008, 01:48 PM
=?Utf-8?B?RGFsZSBGeWU=?=
 
Posts: n/a
RE: Query without field name

If the field name will change, but the columns are in the correct order, you
could build your query in code.

Public Function fnBuildSQL(TableName as string) as String

Dim tdf as dao.tabledef
Dim strSQL as string

Set tdf = currentdb.tabledefs(TableName)

strSQL = "SELECT [" & tdf.fields(1).Name & "], " _
& "[" & tdf.fields(2).Name & "], " _
& "[" & tdf.fields(3).Name & "] " _
& "FROM [" & TableName & "]"

fnBuildSQL = strSQL

End Function

Then, if you have a saved query that you want to call every time, then you
would do something like:

currentdb.querydefs("SavedQueryName").SQL = fnBuildSQL

--
HTH
Dale

Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.



"Behrooz Zamirian" wrote:

> Hi;
> Column name in A table that I import be changed periodically. Therfore, I
> must change my query design.
> How I can write a select statment only with column no. in design list of a
> table.
> (for exp. a statment like this: "Select Column[1], Column[3] from myTable")

Reply With Quote
Reply

  { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Microsoft > MS Office > Access


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 04:20 PM.


Powered by vBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
© 1999-2008 mindfrost82.com v11.0


Sponsors:
Loan | Myspace Codes | Discount Magazine | MPAA | Free Online Games



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114