kashif.special2005
Registered User.
- Local time
- Tomorrow, 05:14
- Joined
- Jan 19, 2011
- Messages
- 19
Hi,
I have a table in ms-access like below
Steve
East
DB
BOA
Jhonson
East
DB
BIO
Josh
East
DB
EBOA
Derek
East
DC
BOA
Haroon
East
DC
EBOA
Aman
East
DC
BIO
I want to take Associate_Name in recordset, and I am using below code
Sub Fetching_Data()
Dim rs As ADODB.Recordset
Dim str_sql As String
str_sql = "select [Associate_Name] from Associates where ([Role] like '*BOA*' Or [Role] Like '*EBOA*')" & _
"And [Domain]='" & Me.cmbdomian & "'" & "And [Region]='" & Me.cmbregion & "'" & "group by [Associate_Name] order by [Associate_Name];"
Set rs = New ADODB.Recordset
With rs
.ActiveConnection = CurrentProject.Connection
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.Open str_sql
End With
If Not rs.EOF Then
rs.MoveLast
Debug.Print rs.RecordCount
End If
It is not giving me any error message but no record showing in recordset, but when I am manually running str_sal query it is giving me result like below
Josh
Steve
"select [Associate_Name] from Associates where ([Role] like '*BOA*' Or [Role] Like '*EBOA*')" & _
"And [Domain]='" & Me.cmbdomian & "'" & "And [Region]='" & Me.cmbregion & "'" & "group by [Associate_Name] order by [Associate_Name];"
Will show
select [Associate_Name] from Associates where ([Role] like '*BOA*' Or [Role] Like '*EBOA*')And [Domain]='DB' And [Region]='East' group by [Associate_Name] order by [Associate_Name];
Please help me to solve this problem.
Thanks
Kashif
I have a table in ms-access like below
Associate_Name
Region
Domain
Role
East
DB
BOA
Jhonson
East
DB
BIO
Josh
East
DB
EBOA
Derek
East
DC
BOA
Haroon
East
DC
EBOA
Aman
East
DC
BIO
I want to take Associate_Name in recordset, and I am using below code
Sub Fetching_Data()
Dim rs As ADODB.Recordset
Dim str_sql As String
str_sql = "select [Associate_Name] from Associates where ([Role] like '*BOA*' Or [Role] Like '*EBOA*')" & _
"And [Domain]='" & Me.cmbdomian & "'" & "And [Region]='" & Me.cmbregion & "'" & "group by [Associate_Name] order by [Associate_Name];"
Set rs = New ADODB.Recordset
With rs
.ActiveConnection = CurrentProject.Connection
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.Open str_sql
End With
If Not rs.EOF Then
rs.MoveLast
Debug.Print rs.RecordCount
End If
It is not giving me any error message but no record showing in recordset, but when I am manually running str_sal query it is giving me result like below
Associate_Name
Steve
"select [Associate_Name] from Associates where ([Role] like '*BOA*' Or [Role] Like '*EBOA*')" & _
"And [Domain]='" & Me.cmbdomian & "'" & "And [Region]='" & Me.cmbregion & "'" & "group by [Associate_Name] order by [Associate_Name];"
Will show
select [Associate_Name] from Associates where ([Role] like '*BOA*' Or [Role] Like '*EBOA*')And [Domain]='DB' And [Region]='East' group by [Associate_Name] order by [Associate_Name];
Please help me to solve this problem.
Thanks
Kashif