1 Attachment(s)
[RESOLVED] Search using a bottom
Hi!
I need if you can help me
I have arraybuttom to show items but I need to search by categories:
For example:
If I Click "Coffee" this have to show me just coffee and the same for
the others Categories: "Combos","Beer","Coffee","Coke","Pastas","Sandwish"
I show those items in 23 an LabelsArray
I have two bottom too "Back" and "Next" if Press Next I have to show more categories:
"Bread", "Rice", "Juice", "Cake".
The Id for this items in the data base:
Combos = 1
Beer = 2
Coffee = 3
Pastas = 4
Sandwish = 5
Bread = 6
Rice = 7
Juice = 8
Cake = 9
I'm Using ADO
Elvis Cabral
Re: Search using a bottom
So basically you have a series of buttons that you can change what they say right? Like if you hit the next button one of your buttons will say "bread" instead of "fish"?
The easiest way I think would be to put the list of button names in an array by order of the numbers you are going to search the database with something like :
Code:
Public arItemList(1 To 23)
arItemList(1) = "Combos"
arItemList(2) = "Beer"
...
arItemList(23) = "Whatever"
Then when you set the caption property of the button also set the tag property to the array index number.
And on a side note it might be a good idea to change the location/ color/ shape of the next and back buttons otherwise your user will get confused.
Re: Search using a bottom
Hi Veritas thank to reply me but infact I'm not reading those item from the database I have those Item in array and then put them
in the buttom if I press next this have to show me "Toast","Sandwish","Cake","Salad", "Spaguettis","Coke" then if I press Next
"Bread", "Juice","Combos","Rice" then same for the others
In this function every time that I press next aways show me "Toast","Sandwish","Cake","Salad", "Spaguettis","Coke", I need that show me the others items. I'm trying to figure it out too if I click "Toast" have to show me all type of "Toast" from the data base and fill those type of "Toast"
into arraylabel.
Code:
Private Function Categories(Optional ByVal sNumber As Integer)
Dim i As Integer
Dim itemList(0 To 14) As String
itemList(0) = "Toast"
itemList(1) = "Sandwish"
itemList(2) = "Cake"
itemList(3) = "Salad"
itemList(4) = "Spaguettis"
itemList(5) = "Coke"
itemList(6) = "Bread"
itemList(7) = "Juice"
itemList(8) = "Combos"
itemList(9) = "Rice"
itemList(10) = "Ice Cream"
itemList(11) = "Beer"
itemList(12) = "Wine"
itemList(13) = "Coffee"
For i = 0 To 5
cmdCategories(i).Caption = itemList(i)
Next i
End If
Hope you can help me :cry:
Elvis Cabral
Re: Search using a bottom
What is the code in your Next button?
Also, how are you going "Back"?
Re: Search using a bottom
I'm confuse I don't know what to set in the next buttom and the back buttom please help
Re: Search using a bottom
Just an idea, but perhaps if you arrange the buttons, and have them into a control array, you'll find it easier to understand the concept and code it:
Please pardon the cheap Ascii art. :)
[BUtton(0)] [Button(2)] [Button(4)] [Button(6)]
[Button(1)] [Button(3)] {Button(5)] [Button(7)]
[BtnBck]---------------------------[BtnFwd]
This way, when you press the next or back buttons, you will find it easier since you only have to jump 2 items in the array instead of a complex argorithm to get your 1-2-2-1 currently.
Re: Search using a bottom
Well, I did this, but I don't know if is good Idea what do you think
Code:
Private Sub cmdNext_Click()
Dim i As Integer
Dim iteml(5) As String
iteml(0) = "Toast"
iteml(1) = "Sandwish"
iteml(2) = "Cake"
iteml(3) = "Salad"
iteml(4) = "Spaguettis"
iteml(5) = "Coke"
For i = 0 To 5
cmdCategories(i).Caption = iteml(i)
Next i
End sub
Code:
Private Sub cmdBack_Click()
Dim itemlist(5) As String
itemList(6) = "Bread"
itemList(7) = "Juice"
itemList(8) = "Combos"
itemList(9) = "Rice"
itemList(10) = "Ice Cream"
itemList(11) = "Beer"
For i = 0 To 5
cmdCategories(i).Caption = itemli(i)
Next i
End Sub
Re: Search using a bottom
Note: This is not tested & off the head, so might require a few tweaks.
Code:
Private itemList(0 To 14) As String 'General Decs
Private Sub Form_Load()
itemList(0) = "Toast"
itemList(1) = "Sandwish"
itemList(2) = "Cake"
itemList(3) = "Salad"
itemList(4) = "Spaguettis"
itemList(5) = "Coke"
itemList(6) = "Bread"
itemList(7) = "Juice"
itemList(8) = "Combos"
itemList(9) = "Rice"
itemList(10) = "Ice Cream"
itemList(11) = "Beer"
itemList(12) = "Wine"
itemList(13) = "Coffee"
Categories 0
End Sub
'//Usage: Categories 6 (For Next button)
'//Usage: Categories 0 (For Back button)
'//For every next or Back button increase by the number of buttons there are:
call Categories 0
Private Function Categories(ByVal startFrom As Integer)
Dim i As Integer
For i = startFrom to Ubound(itemList)
cmdCategories(i).Caption = itemList(i)
Next i
End Sub
1 Attachment(s)
Re: Search using a bottom
Friend, I am including a sample. Have a look at it. I used DAO. You can convert it into ADO
Hope you are fine..:)
Re: Search using a bottom
Thanks a lot akhileshbc this can help me in case if I need to use from the data base I'll always appreciate you help. I'm trying to use an array but if you have another solution I'll aprecciate too.
Hi some1uk03:
I was trying to figure it out but i got an error "Control array element '6' doesn' exit" I don't need array six because I need to go throught the array that in the Index of each button.
Elvis Cabral
1 Attachment(s)
Re: Search using a bottom
Friend, the following is an array version of what you want....:p
Have a look at it...:blush:
Re: [RESOLVED] Search using a bottom
Thanks a lot my friend akhileshbc
Finally my application is running perfect!
Thanks for you help
Elvis Cabral
Re: [RESOLVED] Search using a bottom