Dear Seniors,
I am new to VBA and I seek your help
My logic is to have primary key on both columns CMP_ID & CmP_ID_Char.
Table Company
Fields Cmp_ID Number , Cmp_ID_char Text
DATA
Cmp_ID Cmp_ID_Char
1 Black
1 Red
2 Black
1 White
2 Red
In Vba code i want to run a SQL Query which can give me max(cmp_id) with group by cmp_id_char.. so i now the max numberr of black, red, white. etc
i run this query in acces builder and resluts with good. but same query does not fecth any records. Recordset Eof & BOF are ture..
Dim Max_Dbs As DAO.Database
Dim max_Rst As DAO.Recordset
Dim Tmp_Cmp_Char As String
Dim MySql As String
Set Max_Dbs = OpenDatabase("d:\access qoute new try\qt.accdb")
MySql = "select max(cmp_id) from tbl_company where cmp_id_char= ' " & Txt_Cmp_Char & " ' group by cmp_id_char"
Set max_Rst = Max_Dbs.OpenRecordset(MySql)
here. Max_rst bof and eof are true...
tell me where am i wrong..
Txt_cmp_Char is a text box to input.(i tried both cases. upper and lower)