A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

vba Query for column name



 
 
Thread Tools Display Modes
  #1  
Old September 11th, 2005, 08:56 PM
ismail
external usenet poster
 
Posts: n/a
Default vba Query for column name

Please help me in this issue....here is my code..and tabel struct.

column name datatype

dateofS date
stid number
stname text
petrol number
dessel number
store number
oils number
totalS number


in the form i have 3 combo box list
in first combo i have values like petrol,dessel,store,oils (user may select
any one of this)
in second i have stid (user may select 1 or 2 or 3......etc)
in third i will select the date value (01/09/2005 or 02/06/2005......)

my query as follows...



Dim strSQL As String
Dim d8, d9 As Variant

d8 = Forms!searchfrm!activitycmb
strSQL = "SELECT " & d8 & ",dateofS,totalS ,stid FROM details where stid=" &
Forms!searchfrm!stidcmb & ""
strSQL = Replace(strSQL, " & Forms!searchfrm!stidcmb & ",
Forms!searchfrm!activitycmb)


activitycmb will give petrol or dissel or oil etc....
forms!searchfrm!stidcmb will give stid



Set r1s = asDB.OpenRecordset(strSQL)

Me.RecordSource = strSQL
r1s.MoveFirst
Do While r1s.EOF = False

Me.Text8.ControlSource = Forms!searchfrm!activitycmb
r1s.MoveNext
Loop

it is working fine i am able to display the values petrol or dissel etc..in
my report
my Question is how can display other values in the query like dateofS,totalS
,stid.


please help me i am very much confussed..

Thanks in advance
  #2  
Old September 12th, 2005, 01:54 PM
JohnFol
external usenet poster
 
Posts: n/a
Default

If the combo has the column count higher than 1 (to accomodate the other
fields) you can reference them in much the same way you do with this line

Me.Text8.ControlSource = Forms!searchfrm!activitycmb

Stick another text box on and try this
Me.NewTextBoxName.ControlSource = Forms!searchfrm!activitycmb.column(1)





"ismail" wrote in message
...
Please help me in this issue....here is my code..and tabel struct.

column name datatype

dateofS date
stid number
stname text
petrol number
dessel number
store number
oils number
totalS number


in the form i have 3 combo box list
in first combo i have values like petrol,dessel,store,oils (user may
select
any one of this)
in second i have stid (user may select 1 or 2 or 3......etc)
in third i will select the date value (01/09/2005 or 02/06/2005......)

my query as follows...



Dim strSQL As String
Dim d8, d9 As Variant

d8 = Forms!searchfrm!activitycmb
strSQL = "SELECT " & d8 & ",dateofS,totalS ,stid FROM details where stid="
&
Forms!searchfrm!stidcmb & ""
strSQL = Replace(strSQL, " & Forms!searchfrm!stidcmb & ",
Forms!searchfrm!activitycmb)


activitycmb will give petrol or dissel or oil etc....
forms!searchfrm!stidcmb will give stid



Set r1s = asDB.OpenRecordset(strSQL)

Me.RecordSource = strSQL
r1s.MoveFirst
Do While r1s.EOF = False

Me.Text8.ControlSource = Forms!searchfrm!activitycmb
r1s.MoveNext
Loop

it is working fine i am able to display the values petrol or dissel
etc..in
my report
my Question is how can display other values in the query like
dateofS,totalS
,stid.


please help me i am very much confussed..

Thanks in advance



  #3  
Old September 14th, 2005, 08:04 AM
ismail
external usenet poster
 
Posts: n/a
Default

Kindly look into this matter....if i use xxxxxx.column(1) i get error message
runtime error 451
"property let procedure not difined and property get procedure did not
return object"

i would like to display in my rpt...the other fields from my query..

thanks



"JohnFol" wrote:

If the combo has the column count higher than 1 (to accomodate the other
fields) you can reference them in much the same way you do with this line

Me.Text8.ControlSource = Forms!searchfrm!activitycmb

Stick another text box on and try this
Me.NewTextBoxName.ControlSource = Forms!searchfrm!activitycmb.column(1)





"ismail" wrote in message
...
Please help me in this issue....here is my code..and tabel struct.

column name datatype

dateofS date
stid number
stname text
petrol number
dessel number
store number
oils number
totalS number


in the form i have 3 combo box list
in first combo i have values like petrol,dessel,store,oils (user may
select
any one of this)
in second i have stid (user may select 1 or 2 or 3......etc)
in third i will select the date value (01/09/2005 or 02/06/2005......)

my query as follows...



Dim strSQL As String
Dim d8, d9 As Variant

d8 = Forms!searchfrm!activitycmb
strSQL = "SELECT " & d8 & ",dateofS,totalS ,stid FROM details where stid="
&
Forms!searchfrm!stidcmb & ""
strSQL = Replace(strSQL, " & Forms!searchfrm!stidcmb & ",
Forms!searchfrm!activitycmb)


activitycmb will give petrol or dissel or oil etc....
forms!searchfrm!stidcmb will give stid



Set r1s = asDB.OpenRecordset(strSQL)

Me.RecordSource = strSQL
r1s.MoveFirst
Do While r1s.EOF = False

Me.Text8.ControlSource = Forms!searchfrm!activitycmb
r1s.MoveNext
Loop

it is working fine i am able to display the values petrol or dissel
etc..in
my report
my Question is how can display other values in the query like
dateofS,totalS
,stid.


please help me i am very much confussed..

Thanks in advance




 




Thread Tools
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 On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Toolbars, Drop-Down Menus Rick New Users 1 September 21st, 2005 11:17 AM
SQL query showing diff between actual and budget Bon Running & Setting Up Queries 3 August 25th, 2005 12:07 PM
Nested in-line Query laura Running & Setting Up Queries 0 February 11th, 2005 12:17 AM
Here's a shocker Mike Labosh General Discussion 2 October 26th, 2004 05:04 PM
Too Few Parameters error Mail Merge Access Parameter Query Tony_VBACoder Mailmerge 3 September 14th, 2004 12:15 PM


All times are GMT +1. The time now is 08:47 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.