Really need help today if possible

  • Thread starter Thread starter Heather
  • Start date Start date
H

Heather

I need to display the result in SQLWhere in this section
into a Status sheet in my workbook and thought I should
somehow do this at the end of this routine but the problem
is that I need to display GroupID in one column and
ClassId in another etc.... and the message box doesn't
display it like that... Can someone please help me adjust
this code to be able to put the result of this into a
worksheet????? I really need this by tomorrow if at all
possible... They can have for ex. 1 groupID and 5
Classid's.. THANK YOU, THANK YOU!!!!

Public Sub CommandButtonNextGroupId_Click()
Dim i As Integer
Dim j As Integer

GroupCnt = GroupCnt + 1
If GroupCnt > 1 Then SQLWhere = SQLWhere + " Or "
SQLWhere = SQLWhere + "(GroupId = '" +
InputForm.GroupIdInput + "' "
InputForm.GroupIdInput.Value = ""

' Clear ListBoxClass
j = 0
For i = 0 To intNumReturnedC - 1

If InputForm.ListBoxClass.Selected(0) = True Then
j = j + 1
If j = 1 Then SQLWhere = SQLWhere + "And ClassId in
("
If j > 1 Then SQLWhere = SQLWhere + ", "
SQLWhere = SQLWhere + "'" +
InputForm.ListBoxClass.List(0, 0) + "'"
End If

InputForm.ListBoxClass.RemoveItem 0
Next
If j > 0 Then SQLWhere = SQLWhere + ") "

' Clear ListBoxPlan
j = 0
For i = 0 To intNumReturnedP - 1

If InputForm.ListBoxPlan.Selected(0) = True Then
j = j + 1
If j = 1 Then SQLWhere = SQLWhere + "And PlanId in ("
If j > 1 Then SQLWhere = SQLWhere + ", "
SQLWhere = SQLWhere + "'" + RTrim
(InputForm.ListBoxPlan.List(0, 0)) + "'"
End If

InputForm.ListBoxPlan.RemoveItem 0
Next
If j > 0 Then SQLWhere = SQLWhere + ") "

' Clear ListBoxBusCat
j = 0
For i = 0 To intNumReturnedB - 1

If InputForm.ListBoxBusCat.Selected(0) = True Then
j = j + 1
If j = 1 Then SQLWhere = SQLWhere + "And BusCat in ("
If j > 1 Then SQLWhere = SQLWhere + ", "
SQLWhere = SQLWhere + "'" +
InputForm.ListBoxBusCat.List(0, 0) + "'"
End If

InputForm.ListBoxBusCat.RemoveItem 0
Next

If j > 0 Then SQLWhere = SQLWhere + ") "
SQLWhere = SQLWhere + ") "
MsgBox SQLWhere
End Sub
 
Hello Heather,

I'm not sure it's what you want, but try the following format

SQLWhere = GroupID & vbTab & ClassID & Chr(13)

You will need to put the vbTab and Chr(13) instances in the appropriate
places of your loops.

HTH, Greg
 
I'm not sure of exactly what you are trying to do, but if I understand
you correctly, you would like to have the following type of results:

In Cell B3 (Random pick) -> Group ID
In Cell C3 (Again Random) -> ClassID
In B4 -> 2343 (Group ID)
In C4 -> 12 (Class ID)
In B5 -> 2343
In C5 -> 18

Results look like:

Group ID Class ID
2343 12
2343 18

If this is the case, then the easiest solution would be to populate
the spreadsheet as part of your routine. I would build a subroutine
to put the data out, with static variables maintaining your location
within the spreadsheet.

Alternatively, you could build an array (or some other structure) to
store the values and then put them on the spreadsheet at the end.

To put data onto a spreadsheet (if that is part of the question)
Cell(rowNumber, ColumnNumber).value = YourVariable Goes Here.

You may need to specify the sheet, &/or workbook that you would like
to use.
WorkSheet("Sheet2").cell....

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top