I’d like to confirm please if my record set looks like this:
// Get the values from the current row
Dim value0 As String = rs.Field("custID").StringValue
Dim value1 As String = rs.Field("custCompany").StringValue
Dim value2 As String = rs.Field("custName").StringValue
Dim value3 As String = rs.Field("custTel").StringValue
Dim value4 As String = rs.Field("custMob").StringValue
Dim value5 As String = rs.Field("custEmail").StringValue
// Add a new row to the list box with the retrieved values
CustActiveListBox.AddRow(value0, value1, value2, value3, value4, value5)
Is this the correct way to store the custID as a variable?
//Store the custID so it can be used in the DoublePressed event
CustActiveListBox.RowTagAt(CustActiveListBox.RowCount - 1) = value0
If you guys answer; yes. Then I have a follow up question
I read somewhere that the encoding for sqlite defaulted and that it was best left alone unless absolutely necessary. however i’m obviously open to suggestions.
so i came here to ask one question but it turns out that even the bit that i thought ‘ok’ isnt ‘ok’
thank you. Can lastRowIndex be used in a loop though?
so anyway, my follow up question is. Assuming I have stored the custID variable correctly. How can put that variable into a DoublePressed event?
Basically the user double clicks a row of data the custID needs to be used and passed to my method which holds a sql query. Sorry if that sounds like gibberish
Dim xValue, yValue, row, column As Integer
xValue = System.MouseX - Me.Left - Self.Left // Calculate current mouse position relative to top left of ListBox
yValue = System.MouseY - Me.Top - Self.Top // Calculate current mouse position relative to top of ListBox.
row = Me.RowFromXY(xValue, yValue)
YourMethod(me.RowTagAt(row))
thank you. Yes this is the coordinate method i was reading about. It sounded complicated!
So with your example…
Dim xValue, yValue, row, column As Integer (the error says this is an unused variable)
and if I change this line YourMethod(me.RowTagAt(row)) to be:
ShowEditCustomer(me.RowTagAt(row))
it says that ShowEditCustomer does not exist. But obviously it does exist. These are the kind of problems that I come across and don’t understand.
2, ShowEditCustomer is a method of the EditCustomer window. The ShowEditCustomer method holds the sql query which pulls the customer data and then I specify which bits of data goes in which text fields.
You should be passing, to the new window, the minimum of data needed to do the work there, in this case the custID from the listbox. Then the new window should do all the work and you should call that method there.
On all my similar windows I have a method called winShow, such as this (adapted to your situation) called thus from the double-pressed code:
otherwindow.winshow (custid)
and then winshow looks like:
localcustid = custid
me.show ()
localcustid is a property of otherwindow and is used to store the paramter passed to the window. You can extend that easily enough for more parameters. That way everything is local to where it is used.
yes! this is what i have been attempting to do. I’m glad you’ve just written that. But this refers back to my original question above… I’m not convinced that I am storing the custID variable correctly. because all I ever seem to get is: custID does not exist.
so i have been attempting to store the custID with:
//Store the custID so it can be used in the DoublePressed event
CustActiveListBox.RowTagAt(CustActiveListBox.RowCount - 1) = value0
It has been suggested here that it would be better to use LastRowIndex instead of RowCount
would this still be contained within the loop of the list box?
so in here:
// The loop through
While Not rs.EOF
// Get the values from the current row
Dim value0 As String = rs.Field("custID").StringValue
Dim value1 As String = rs.Field("custCompany").StringValue
Dim value2 As String = rs.Field("custName").StringValue
Dim value3 As String = rs.Field("custTel").StringValue
Dim value4 As String = rs.Field("custMob").StringValue
Dim value5 As String = rs.Field("custEmail").StringValue
// Add a new row to the list box with the retrieved values
CustActiveListBox.AddRow(value0, value1, value2, value3, value4, value5)
//in here?????
// next row
rs.MoveNext
Wend
rs.Close
Yes, step one is populating the listbox and the rowtags, then in the double-pressed event you get hold of the relevant custid value and pass it to the other window for processing.