Filling listbox and textbox of a different form ... excel vba

instanceoftime

Board Regular
Joined
Mar 23, 2011
Messages
102
I am using a scan gun to enter info (which is why I am using 3 forms since the click event only works for the first command box) (and don't want message boxes)
anyhow all the infor is in an array and I am trying to write back to form1(frmPricer) how can I do that?

Code:
Private Sub cmdEnter_Click()
    Dim str7 As String, str8 As String, str9 As String, str10 As String, str11 As String, str12 As String
    Dim NotFound As Integer
    Dim arr As Variant
    Dim I As Long
    Dim Price As Currency


    NotFound = 0
    
    ActiveWorkbook.Sheets("Items").Activate
    
    Price = txtbxPrice.Text
    
        
    If Price <> False Then


            With ActiveSheet
                arr = .Range("A1:H" & .Cells(.Rows.Count, "A").End(xlUp).Row)
            End With
    
            For I = 1 To UBound(arr)
                If arr(I, 7) = UPCNumber Then
                    str7 = IIf(str7 = "", arr(I, 1), str7 & "|" & arr(I, 1))
                    str8 = IIf(str8 = "", arr(I, 2), str8 & "|" & arr(I, 2))
                    str9 = IIf(str9 = "", arr(I, 3), str9 & "|" & arr(I, 3))
                    str10 = IIf(str10 = "", arr(I, 4), str10 & "|" & arr(I, 4))
                    str11 = IIf(str11 = "", arr(I, 7), str11 & "|" & arr(I, 7))
                    str12 = IIf(str12 = "", arr(I, 8), str12 & "|" & arr(I, 8))
                    Cells(I, 8).Value = (Price)
[COLOR=#ff0000]                    frmPricer.lbxItemNumber.List = Split(str7, "|")           [/COLOR]
[COLOR=#ff0000]                    frmPricer.lbxDescription.List = Split(str8, "|")[/COLOR]
[COLOR=#ff0000]                    frmPricer.lbxCost.List = Split(str9, "|")[/COLOR]
[COLOR=#ff0000]                    frmPricer.lbxDate.List = Split(str10, "|")[/COLOR]
[COLOR=#ff0000]                    frmPricer.lbxUPCNumber.AddItem (Response2)[/COLOR]
[COLOR=#ff0000]                    frmPricer.lbxPrice.AddItem (Price)[/COLOR]
                    Unload Me
                    Unload frmAddUPC
                End If
            Next
    End If
    


End Sub
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
What problems are you having?

Errors?

Wrong data being populated to the controls?
 
Upvote 0
data isn't loading. I'm not throwing any errors. stepping through I show everything on the right side of the code in red above shows the correct value
 
Upvote 0
Why are you setting the lists of lbxItemNumber, lbxDescription etc multiple times and unloading the form the code is in and frmAddPC repeatedly?

Where are the values Response2 and Price?
 
Upvote 0
the listboxes are being filled with occurrences as they are found. for example: Everyone named john would fill the listboxes with their accompanying info

The spreadsheet & code:
What I am doing using form1(frmPricer) to seach for all occurrences of a UPC. (if found great .. all the info is presented in the listboxes)
if the UPC isn't in the spreadsheet I go to form2(frmAddUPC) and search by a different number (item number). (It then adds the previous UPC to the spreadsheet.) If this is found I go to form3(frmAddPrice).
on this form I scan in a PRICE from text box to be added to the spreadsheet as well.
response2 if a global variable (scan of the item number from previous form)
 
Last edited:
Upvote 0
If you unload the form the code is in the code will stop executing.
 
Upvote 0
ok, I got the data to pass with the code above.... memo to myself and others... had the listboxes in a frame .. which evidently creates a problem

Thanks Norie
 
Upvote 0

Forum statistics

Threads
1,215,326
Messages
6,124,260
Members
449,149
Latest member
mwdbActuary

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top