Query Help

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a table1 in which the information is like this:

[FIELD1] [FIELD2]
A 1
A 6
A 42
B 7
B 10

I want to display the information in a continous form1 like this:

[FIELD] [FIELDZ]
A 1, 6, 42
B 7, 10

I have tried a concatenate function for FIELDZ in the control source. -
=Concatenate("SELECT FIELD2 FROM TABLE1 WHERE FIELD1=Forms!Form1![FIELD]").

When ever i try to put a where fucntion in that isn't static eg field1=A, i
get an error.

Is my statement wrong, or am i going about this the wrong way.

TIA
 
Try:

=Concatenate("SELECT FIELD2 FROM TABLE1 WHERE FIELD1= '" &
Forms!Form1![FIELD] & "'")

or, if Field1 might contain single quotes:

=Concatenate("SELECT FIELD2 FROM TABLE1 WHERE FIELD1= " Chr$(34) &
Forms!Form1![FIELD] &Chr$(34))

Note that the first one is

=Concatenate("SELECT FIELD2 FROM TABLE1 WHERE FIELD1= ' " &
Forms!Form1![FIELD] & " ' " )
 
Thanks Douglas,

The first gives a name? error and the second one i get a syntax error, which
i did try to resolve, to no avail.

Any other ideas

Thanks

Douglas J Steele said:
Try:

=Concatenate("SELECT FIELD2 FROM TABLE1 WHERE FIELD1= '" &
Forms!Form1![FIELD] & "'")

or, if Field1 might contain single quotes:

=Concatenate("SELECT FIELD2 FROM TABLE1 WHERE FIELD1= " Chr$(34) &
Forms!Form1![FIELD] &Chr$(34))

Note that the first one is

=Concatenate("SELECT FIELD2 FROM TABLE1 WHERE FIELD1= ' " &
Forms!Form1![FIELD] & " ' " )

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


rico said:
I have a table1 in which the information is like this:

[FIELD1] [FIELD2]
A 1
A 6
A 42
B 7
B 10

I want to display the information in a continous form1 like this:

[FIELD] [FIELDZ]
A 1, 6, 42
B 7, 10

I have tried a concatenate function for FIELDZ in the control source. -
=Concatenate("SELECT FIELD2 FROM TABLE1 WHERE FIELD1=Forms!Form1![FIELD]").

When ever i try to put a where fucntion in that isn't static eg field1=A, i
get an error.

Is my statement wrong, or am i going about this the wrong way.

TIA
 
Sorry, i had the first one mistyped, i now get a data type mismatch pop up!

Douglas J Steele said:
Try:

=Concatenate("SELECT FIELD2 FROM TABLE1 WHERE FIELD1= '" &
Forms!Form1![FIELD] & "'")

or, if Field1 might contain single quotes:

=Concatenate("SELECT FIELD2 FROM TABLE1 WHERE FIELD1= " Chr$(34) &
Forms!Form1![FIELD] &Chr$(34))

Note that the first one is

=Concatenate("SELECT FIELD2 FROM TABLE1 WHERE FIELD1= ' " &
Forms!Form1![FIELD] & " ' " )

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


rico said:
I have a table1 in which the information is like this:

[FIELD1] [FIELD2]
A 1
A 6
A 42
B 7
B 10

I want to display the information in a continous form1 like this:

[FIELD] [FIELDZ]
A 1, 6, 42
B 7, 10

I have tried a concatenate function for FIELDZ in the control source. -
=Concatenate("SELECT FIELD2 FROM TABLE1 WHERE FIELD1=Forms!Form1![FIELD]").

When ever i try to put a where fucntion in that isn't static eg field1=A, i
get an error.

Is my statement wrong, or am i going about this the wrong way.

TIA
 
Can you determine exactly what the SQL statement being passed to the
Concatenate function is?

Presumably it needs to be something like SELECT FIELD2 FROM TABLE1 WHERE
FIELD1= 'A'

Once you know what SQL is being passed, try calling the Concatenate function
yourself, pass it that exact string.

Since there's no Concatenate function in Access, I'm assuming it's a
user-defined function in your application: without knowing anything about
it, it's essentially impossible for me to help.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


rico said:
Sorry, i had the first one mistyped, i now get a data type mismatch pop up!

Douglas J Steele said:
Try:

=Concatenate("SELECT FIELD2 FROM TABLE1 WHERE FIELD1= '" &
Forms!Form1![FIELD] & "'")

or, if Field1 might contain single quotes:

=Concatenate("SELECT FIELD2 FROM TABLE1 WHERE FIELD1= " Chr$(34) &
Forms!Form1![FIELD] &Chr$(34))

Note that the first one is

=Concatenate("SELECT FIELD2 FROM TABLE1 WHERE FIELD1= ' " &
Forms!Form1![FIELD] & " ' " )

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


rico said:
I have a table1 in which the information is like this:

[FIELD1] [FIELD2]
A 1
A 6
A 42
B 7
B 10

I want to display the information in a continous form1 like this:

[FIELD] [FIELDZ]
A 1, 6, 42
B 7, 10

I have tried a concatenate function for FIELDZ in the control source. -
=Concatenate("SELECT FIELD2 FROM TABLE1 WHERE FIELD1=Forms!Form1![FIELD]").

When ever i try to put a where fucntion in that isn't static eg
field1=A,
i
get an error.

Is my statement wrong, or am i going about this the wrong way.

TIA
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top