Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi, I'm trying to select the Max of a column that stores an Id of reunions so it can pass that value always when submitting in other forms Attendance, names of people etc

Here's the code

VB
("SELECT MAX(ASAM_ID_ASAMBLEA) AS ASAM_ID_ASAMBLEA FROM tblCOOPERATIVA " & _
                                                      "JOIN tblASAMBLEA  ON tblASAMBLEA.ASAM_ID_ASAMBLEA = tblCOOPERATIVA.ASAM_ID_ASAMBLEA", conn)


Please Help. Thank you, if you need any more info let me know

The main column name is ASAM_ID_ASAMBLEA then on the other tables I have the same Column name

I just want to pass that first ASAM_ID_ASAMBLEA value into the other and always looking the MAX (or last one register) into my other tables
Posted
Updated 5-Apr-13 3:46am
v5
Comments
CHill60 5-Apr-13 9:22am    
Does table tblCOOPERATIVA actually have a column called MaxId?
TesterJSR 5-Apr-13 9:36am    
no
TesterJSR 5-Apr-13 9:39am    
I have changed it but it is still ambiguous

("SELECT MAX(ASAM_ID_ASAMBLEA) AS ASAM_ID_ASAMBLEA FROM tblCOOPERATIVA " & _
"JOIN tblASAMBLEA ON tblASAMBLEA.ASAM_ID_ASAMBLEA = tblCOOPERATIVA.ASAM_ID_ASAMBLEA", conn)
CHill60 5-Apr-13 9:42am    
Could you use the Improve question link to post the table schema for these tables so I can see if I can point you in the right direction
TesterJSR 5-Apr-13 9:44am    
Sure

1 solution

The MAX(ASAM_ID_ASAMBLEA) part of your query does not now from which table to take the field. You need to specify the table name in front of the field.

So either use
SQL
MAX(blASAMBLEA.ASAM_ID_ASAMBLEA)
or
SQL
MAX(tblCOOPERATIVA.ASAM_ID_ASAMBLEA)
 
Share this answer
 
Comments
Maciej Los 6-Apr-13 17:56pm    
+5!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900