| | |
loadin a form
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Jun 2007
Posts: 166
Reputation:
Solved Threads: 9
First try to understand why a form is loaded (made visible). It is either to attract the user with some message or for some input/selection. You are not supposed to write any code other than that in the form load event. Only a control in the form if activated by the user or if it elapse in time in its visibility, then only other procedures should start.
In assence a form actually is a tool to invite the participation of the user for a specific action/s he or she wants to do. Keep that in mind while writing the code inside the form_load. Check up the code inside the form_load(). You will find the actual bug.
In assence a form actually is a tool to invite the participation of the user for a specific action/s he or she wants to do. Keep that in mind while writing the code inside the form_load. Check up the code inside the form_load(). You will find the actual bug.
•
•
Join Date: Jun 2007
Posts: 166
Reputation:
Solved Threads: 9
Take out the codes for db connection and recordset from the called form_load and paste it in the module before the form_load line. When the form_load is invoked from that module control is passed to that form_load(). The recordset is still avilable to you in the just loaded form. open it. Read the required data from the database. Fill the data on the different contols in the form and set focus to any control in the form. There you are.
•
•
Join Date: Jun 2007
Posts: 166
Reputation:
Solved Threads: 9
Natuarally I thought it will happen. First try to declare the variable cnn and recordset as a global varaible so that from any sub you can access them.
Otherwise. you can do one thing. In the module where you invoked the form_load() just pass the recordset to the form_load.
Example
formx_load myRecordeSet
and in the form_load module
Private Sub Formx_Load(myRecordSet)
if both variable are same it is OK
Now I will tell you one simple debugging technique.
Put as many MsgBox in the program where you find you are struck up.
for example in you module where you are trying to accee the form_load
place this line.
MsgBox "I have set up the connection and passed the recordset to the formload "
then place the code
formx_load myRecordSet
Then in the
Private Sub Formx_load(myRecordSet)
MsgBox "I am inside the formx_load and I got the recordset and now I am going to open it"
then Open the record set and select the fields from the Database.
again give
MsgBox "Now I have read the data"
Likewise you can debug beautifully
Otherwise. you can do one thing. In the module where you invoked the form_load() just pass the recordset to the form_load.
Example
formx_load myRecordeSet
and in the form_load module
Private Sub Formx_Load(myRecordSet)
if both variable are same it is OK
Now I will tell you one simple debugging technique.
Put as many MsgBox in the program where you find you are struck up.
for example in you module where you are trying to accee the form_load
place this line.
MsgBox "I have set up the connection and passed the recordset to the formload "
then place the code
formx_load myRecordSet
Then in the
Private Sub Formx_load(myRecordSet)
MsgBox "I am inside the formx_load and I got the recordset and now I am going to open it"
then Open the record set and select the fields from the Database.
again give
MsgBox "Now I have read the data"
Likewise you can debug beautifully
•
•
Join Date: Jun 2007
Posts: 166
Reputation:
Solved Threads: 9
I am very sorry to keep you so long. I have been out.
The only alternative thing can be some thing wrong with your
formx.show
To get hold of the consecutive forms you had to mention with the sow the model
Formx.Show vbModel
Revert the code to the earlier state and change the show in this way.
I think it has to work.
Get back to me immediately if it works or tomorrow I will try to help you.
The only alternative thing can be some thing wrong with your
formx.show
To get hold of the consecutive forms you had to mention with the sow the model
Formx.Show vbModel
Revert the code to the earlier state and change the show in this way.
I think it has to work.
Get back to me immediately if it works or tomorrow I will try to help you.
![]() |
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Passing formname as variable
- Next Thread: deleting record from db using tableadapter
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age append application basic beginner birth bmp calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver subroutine table tags textbox time timer urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows






