Select to view content in your preferred language

update Combobox set to dbf

3551
10
12-17-2010 08:13 AM
JayKappy
Frequent Contributor
I have a project that has a couple dbf tables that are feeding a couple comboboxes.  Whent he app opens the comboboxes are populates with values from the dbf tables.
I then wrote code that allows teh user to update the dbf tables. 
THis works and the dbf files are updated ALTHOUGH these changes are not reflecting when the user clicks the comboboxes the next time.  I have to completly leave the application and start it again.
So this points to the fact that the Comboboxes are being populated on the application open...

So my next question is obvious....how can I force the refresh of these comboboxes after the dbf update. 
If I was loading the comboboxes when they open no problem...but this is something a bit different...I am using ArcPAD to populate the comboboxes by pointing to a dbf table in the list values tab of the combobox. 

Any thoughts?

THanks
Tags (3)
0 Kudos
10 Replies
JayKappy
Frequent Contributor
I think I made a owrk around....but for soem reason it takes about 12-15 seconds to refresh the combobox/listbox...there are about 1200 records in the dbf...

Anyoen knwo of a faster way to do this....and this time taken is from a desktop computer...uggggg
0 Kudos
EricHajek1
Regular Contributor
Would using the .AddItem method on the combobox at the same time you're saving the new DBF entries work? Maybe this is already what you're doing, but it would create the illusion that it's refreshing the DBF-based combobox, but really it's the DBF plus the few new entries. The next time ArcPad gets started up, it will load entirely from the DBF and forget the items you added manually, so it would be pretty seamless to the end user.
0 Kudos
JayKappy
Frequent Contributor
Yea that is what i decided to do....I was seeign a huge reload time on my PC but for soem reason on the laptop it was only a couple seconds...very confusing because the PC is 10 more powerful than the laptop.
Thanks
0 Kudos
ColbyParnell
Emerging Contributor
Jay,  can you post what code you have?  Im trying something similar to what your doing but cant get it to work. 

Thanks,
0 Kudos
JayKappy
Frequent Contributor
This is what I am doign to refresh the combobox after I update or create a new record in the dbf.
Is this what you are refering to or are you talking about updating the dbf?
I simply call this sub

Note is you are usign the DBF as a lookup table then it has to be in the same folder as the .axf file.   (Where you set it in ArcStudio in the listvalues tab of the control properties of the combobox)
If all you are doing is calling it for a query etc then it can be anywhere...

Sub PopulateListBoxMUTCDPage   

  Dim objRS4, objSelLayer4, objEFPageOneControls4, objEditForm4
  Set objSelLayer4 = Map.SelectionLayer
  Set objRS4 = objSelLayer4.Records

  objRS4.Bookmark = Map.SelectionBookmark

  Set objEditForm4 = application.map.layers("Supports").forms("EDITFORM")
  Set objEFPageOneControls4 = objEditForm4.Pages("page3").Controls

   Dim MUTCD_CodeValue
   MUTCD_CodeValue = objEFPageOneControls4("mutcd_code").Value
   'msgbox MUTCD_CodeValue

 objEFPageOneControls4("List1").Clear

' SPECIFY THE PATH TO LOCATE THE DBF FILE FOR QUERYING
 Dim path
    path = "C:\GPS_data_collections\Packets_Outgoing\Support_Signs_Data_Collection_2011\MUTCD_Code.dbf"

    Dim pDS
    Set pDS = Application.CreateAppObject("RecordSet")
     
  pDS.Open(path)

 pDS.Find("MUTCD_CODE")

 pDS.MoveFirst
 Do While Not pDS.EOF

   Dim Description, ObjectID  
   Description = pDS.Fields("MUTCD_CODE").Value
   ObjectID = pDS.Fields("MUTCD_CODE").Value
                   objEFPageOneControls4("List1").AddItem ObjectID, Description 

  pDS.MoveNext 
 Loop

 pDS.Close 
 Set pDS = Nothing
End Sub



WAIT A SECODN I AM CONFUSING MYSELF HERE....THT updates a list box on have on my form...this will update the combobox after saving the record in teh dbf
Call this sub

Sub Save

        ....code to Save or Update the dbf

       Call PopulateMUTCDCodeComboBox

End Sub


Sub PopulateMUTCDCodeComboBox

  Dim objRS4, objSelLayer4, objEFPageOneControls4, objEditForm4
  Set objSelLayer4 = Map.SelectionLayer
  Set objRS4 = objSelLayer4.Records
  objRS4.Bookmark = Map.SelectionBookmark
  Set objEditForm4 = application.map.layers("Supports").forms("EDITFORM")
  Set objEFPageOneControls4 = objEditForm4.Pages("page2").Controls

 objEFPageOneControls4("mutcd_code").Clear

 MsgBox "The MUTCD Code List is Updating, Please hold on!" & vbnewline & "The combobox will populate shortly", vbExclamation, "MUTCD Updating"

 Dim path
 ' Desktop path
    path = "C:\GPS_data_collections\StreetSign_Collection_ArcPAD\Packets_Outgoing\Support_Signs_Data_Collection_2011\MUTCD_Code.dbf"

    Dim pDS
    Set pDS = Application.CreateAppObject("RecordSet")
  pDS.Open(path)
 pDS.Find("MUTCD_CODE")

 pDS.MoveFirst
 Do While Not pDS.EOF
   Dim varMUTCDCode 
   varMUTCDCode = pDS.Fields("MUTCD_CODE").Value
      objEFPageOneControls4("mutcd_code").AddItem varMUTCDCode, varMUTCDCode 
  pDS.MoveNext 
 Loop
 pDS.Close 
 Set pDS = Nothing


End Sub
0 Kudos
RolfBroch
Frequent Contributor
If I read your code correctly it would be easier to use these requests:

objEFPageOneControls4("mutcd_code").Clear
objEFPageOneControls4("mutcd_code").AddItemsFromTable path, "MUTCD_CODE", "MUTCD_CODE"

and not do any looping at all.

Rolf
0 Kudos
JayKappy
Frequent Contributor
If I read your code correctly it would be easier to use these requests: 

objEFPageOneControls4("mutcd_code").Clear 
objEFPageOneControls4("mutcd_code").AddItemsFromTable path, "MUTCD_CODE", "MUTCD_CODE" 

and not do any looping at all. 

Rolf


Something like this?
 objEFPageOneControls4("mutcd_code").Clear

Dim path
path = "C:\GPS_data_collections\StreetSign_Collection_ArcPAD\MUTCD_Code.dbf"

objEFPageOneControls4("mutcd_code").AddItemsFromTable path, "MUTCD_CODE", "MUTCD_CODE"
0 Kudos
RolfBroch
Frequent Contributor
Yep, that looks correct.
0 Kudos
JayKappy
Frequent Contributor
Something weird is going on here....Nothing to do with the code...

That code worked by the way, thanks....


  • I have a Windows 7 machine, 64 bit, Intel Core(TM) 2 Duo CPU, 8 gigs of RAM

  • The update and saving takes about 13-15 seconds.... 
  • I place the same app (ArcPAD) on a Windows XP machine with Dual Core, about 1 gig Ram and it does it in 2-3 seconds....

I have no idea whats going on here....How can my desktop process this so slow and the laptop be so fast?

But anyways I am going to test on the Laptop and see where I am at....THANKS AGAIN.....
0 Kudos