Silly little question about recordset and rowidx

Hi All.

For some reason this is evading me, and I can’t figure this out. I know it might be a simple question, but as I said it evades me.

I have a sqlitedatabase, and when my program runs, I fill in a popupmenu so you can select a person. When this is done, into textfields I want to enter their address and phone number. My popupmenu fills in just fine, and when I do a change, I see the correct index (I just show it in a menu box), but for some reason I can’t get the textfields to fill in.

I’ve tried selectedrowat, and other options but it never fills in.

Any ideas?

Regards

What information are you storing when you populate the popupmenu? Do you store the database record ID in the rowtag? Do you grab all the Person info and put it into a class and store that in the rowtag?

When you tried selectedrowat, what did you try? More detail is needed.

1 Like

Hi Tim.

Sorry for taking so long to get back, but I’ve been up to my ears in troubles at work. But thus is life. I will attempt to get the code for you… away from my “working” computer.

When I have it I will send a response. But while thinking I may have found a solution to my issue. If I figure it out I will share.

Regards

Hi All.

I finally got my fill in the phone numbers issue solved. Might not be the fanciest way but it works.
For anyone who comes after me, this works… for me.

dim techPhoneNumbers as RecordSet // I want the records for the tech phone numbers… duh
dim techPhoneNumbersstring as string // for the sql query

if app.dbfile <> NIL then
App.db = new SQLiteDatabase
App.db.DatabaseFile = app.dbfile

if App.db.Connect then

MessageBox "Connected"
techPhoneNumbersstring = "select * from technicians where techName Like '%"+techAdd1Popup.getString+"%'"
techPhoneNumbers = App.db.sqlSelect (techPhoneNumbersstring)

while not techPhoneNumbers.eof
  
  assistingTechCell.Text = techPhoneNumbers.Field("cellNumber").StringValue
  assistingTechOffice.text = techPhoneNumbers.Field("officeNumber").StringValue
  
  techPhoneNumbers.moveNext
wend

end if
end if

Regards

So what happens when you have two techs whose names match? You only see one of them listed.

Hi Tim.

We don’t have two people with the same name. In that case we would use a middle initial, I guess.

But I did find another issue…
When the entry is written to the database, I clear the fields for a new entry. But that changes the tech popup, and so it wants to find a user again.

Any idea how to get around this?

Regards

Why should clearing the fields change the popup? Or do you mean you’d like it to change the popup?

Hi Tim

To allow for a new event as work progresses. The program is for time management, so if I work with one tech, end my time with him, and start with another tech, I want to clear out everything and select what I need to start working with the next tech.

Regards

RemoveAllRows causes a Changed event if the user had something selected.
The same is true for Listbox.

Hi Tim.

Any ideas (other than the obvious) to stop the change event from firing?

Regards

You can use a flag to know if it’s changing by code. Some people use a property on the window such as bLoading to know that they’re loading, personally I use the control’s enabled state.

At the top of the Changed event, check for this flag (or the enabled state) and return early if the Changed code is not meant to run.

Sub Change() Handles Change
  // Bail if changing by code
  if not me.Enabled then return
  
  // Changed action here

End Sub

Hi Tim.

Sorry for taking so long to get back. Real life… ie my paying job can be such an inconvenience… but that is the solution I found too… using a flag to determine if the change occurred. In my case I put it in the popup for my tech…

Thanks for your help!