Click here to Skip to main content
15,896,207 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want display the information present in the database table i.e. table name is Accessories in that table,fan,chairs etc available then i want to show that fields on form using lable
Posted
Comments
OriginalGriff 11-Feb-12 5:05am    
And what have you tried?

try this

VB
' assuming rst is your Recordset and fld is a Field
for each fld in rst.Fields
label1.Caption = fld.Name ' this will display the name of the field in the label
next
 
Share this answer
 
v2
Comments
Bhags1992 12-Feb-12 7:25am    
i want display the field is in the label
Aniket Yadav 12-Feb-12 7:29am    
Chk the solution, I have improved the solution
Bhags1992 12-Feb-12 7:38am    
here exactly field is what
Aniket Yadav 12-Feb-12 7:49am    
The contents in the database table. Suppose you have a table name login, So their fields are username and password.
Thus these are the fields from the table.

Is this what you want in your label to be displayed?
Bhags1992 12-Feb-12 7:49am    
Dim i As Integer
If cboEventName.Text = "Bday" Then
For i = 0 To 14
lblAcc(i).Caption = rs1.Fields(0).Value
Next i
im using this code
from this i will gel all label cation is same nd here i also want to check for (rs1.Fields(5).Value = "y")
VB
Dim i As Integer
If cboEventName.Text = "Bday" Then
For i = 0 To 14
    for each fld in rs1.Fields
        lblAcc(i).Caption = rs1.Fields
    Next
Next i


Try this
 
Share this answer
 
v2
Comments
Bhags1992 12-Feb-12 8:04am    
but how can i write field name
Bhags1992 12-Feb-12 8:10am    
my field name i.e column name is accessories in that data for each accessory is y or n.so, if the y then only value of that field display is in the label
Bhags1992 12-Feb-12 8:39am    
pls tell na what i write instead of fld
Aniket Yadav 13-Feb-12 0:01am    
Chk The Solution
Try This.
VB
Dim i As Integer
If cboEventName.Text = "Bday" Then
For i = 0 To 14
    for each fld in rs1.Fields
        If(rs1.Fields(fld.Name).Value) = "Y" Then
            lblAcc(i).Caption = rs1.Fields(fld.Name).Value
        End If
    Next
Next i

Accept The Answer If It Has Helped You
 
Share this answer
 
Comments
Bhags1992 13-Feb-12 0:58am    
Accesories Wedding Bday Anniversary Conference

tables y y y n
chairs y y y y
speaker y y y n

my table is in dis format and when i select any event among
dis I want to display accessories which has value y
so what should i write in field name pls tell
Aniket Yadav 13-Feb-12 1:01am    
You Will Get The Value Directly.
fld.Name Itself will give you the field name and (fld.Name).Value will give its value in it. i.e. Y or N.
Also please chk that for each loop is important in this case.
Bhags1992 13-Feb-12 1:05am    
If cboEventName.Text = "Bday" Then
For i = 0 To 14
For Each fld In rs1.Fields
If (rs1.Fields(fld.Name).Value) = "Y" Then
lblAcc(i).Caption = rs1.Fields(fld.Name).Value
End If
Next
Next i
i m using dis code but it gives compile error for each control variables must be variant or object
Aniket Yadav 13-Feb-12 1:15am    
How Many Labels do you have? Bcoz i think the error is due to the counter i.
Please debug the code line by line. It will show you the exact error. Do not press F5.

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