Hello!
I have a form in my database which runs trough 6 different functions at the Form_Open event to fill the form with fresh data.
This takes some time, maybe 2 or 3 seconds to open it. Yesterday we hade to use this form to lookup data on maybe 500 different products and I got a little bit annoyed of the delay. Occasionally it takes upto 20-30 seconds also, but that is not the case.
The code looks like this
The 'fremdriftsindi kator' function updates a progressbar which is a separate form. All the other functions is the ones that take time. They have code in them which opens tables on a SQL server and put the data on the form.
Recently one of our guys which handle VB applications talked to me about multithreading. I am not a proffesionale programmer so i dont know if it can be done, but i can see the advantage if 'Call liste_logidosed ata' can be initiated before 'Call oppdater_produk sjonsdata' is finished.
Maybe even all the function can be launched simultaneously. That would be cool :=)
Anybody have an idea?
I have a form in my database which runs trough 6 different functions at the Form_Open event to fill the form with fresh data.
This takes some time, maybe 2 or 3 seconds to open it. Yesterday we hade to use this form to lookup data on maybe 500 different products and I got a little bit annoyed of the delay. Occasionally it takes upto 20-30 seconds also, but that is not the case.
The code looks like this
Code:
Private Sub Form_Open(Cancel As Integer)
On Error GoTo error_handling
Call Fremdriftsindikator("ja", 11, "Åpner vareinformasjon")
Dim VisBilde As Boolean
Dim Varenummer As Long
Dim rst As New ADODB.Recordset
With rst
.Open "SELECT * from [Main tbl brukere] where brukernavn='" & Brukernavn() & "'", CurrentProject.Connection, adOpenForwardOnly, adLockReadOnly
Varenummer = ![Siste vareinfo brukt]
Me.cmbbox_maskinlokasjoner = ![Vareinfo MaskinLokasjoner]
Me.chkbox_tablettbilde = ![VisVareinfoBilde]
Me.chkbox_nagarainformasjon = !VisNagaraInfo
.Close
End With
Set rst = Nothing
Dim sSql As String
sSql = "SELECT [VARER Vareinformasjon].* FROM [VARER Vareinformasjon] WHERE ((([VARER Vareinformasjon].Varenr)=" & Varenummer & "));"
Me.RecordSource = sSql
Me.Caption = "Vareinformasjon " & Me.tbx_varenr
Call Fremdriftsindikator(, , "Henter opp tablettbilde", , 1)
Call Oppdater_Tablettbilde
'Fjernet dagens prod grunnet uvisst om den har noe for seg å vise
Call Fremdriftsindikator(, , "Beregner produksjonsdata", , 1)
Call oppdater_produksjonsdata
Call Fremdriftsindikator(, , "Henter opp logidosedata", , 1)
Call liste_logidosedata
Call Fremdriftsindikator(, , "Henter informasjon fra Astra", , 1)
Call Astradata
Call Fremdriftsindikator(, , "Henter opp lokasjonsdata", , 1)
Call oppdater_lokasjonsdata
Call Fremdriftsindikator(, , "Beregner lokasjonssliste", , 1)
Call oppdater_lokasjonsinfo
Call Fremdriftsindikator(, , "Henter opp nagaravareinformasjon", , 1)
Call oppdater_nagarainformasjon
Call Fremdriftsindikator(, , "Sjekker varemottak for bestilling", , 1)
Call ventes_varemottak
Call Fremdriftsindikator(, , , "ja")
[Form_INFO Vareinformasjon].tbx_søkestreng.SetFocus
Exit Sub
error_handling:
MsgBox Err.Description
Resume Next
End Sub
Recently one of our guys which handle VB applications talked to me about multithreading. I am not a proffesionale programmer so i dont know if it can be done, but i can see the advantage if 'Call liste_logidosed ata' can be initiated before 'Call oppdater_produk sjonsdata' is finished.
Maybe even all the function can be launched simultaneously. That would be cool :=)
Anybody have an idea?
Comment