Just been through a fun little debugging effort that began when I discovered my form had a ghost!
I'd open the form from a commandbutton and play with the newly openened form via VB. Happily. That is, until I discovered the values I was getting back from VB disagreed with what the form was telling me on screen.
I found out that there were two instances of the form open, one with visible=true and the other visible=false. The first was the one I had opened. The second was opened by aliens, I was forced to conclude. Until I discovered that these two statements produce entirely different results:
1. DoCmd.OpenForm(Form_FormName.Name)
2. DoCmd.OpenForm("FormName")
I had chosen method 1 so that if I changed my form name, I wouldn't have to change my code. Supposedly safer. I never had this problem when I was using .MDBs! However, in a .ADP if you call
Form_FormName.Name
and the form is not open, the project automatically opens a hidden instance to query the property (.Name) and doesn't close it. Hence method 1 opens the form twice. When you query the form in VB, you're actually talking to the initially opened, but hidden, instance of the form.
I guess I was being too tricky for myself!!!
Hope this helps someone somewhere or is interesting to same.
Cheers,
HappyCoda
I'd open the form from a commandbutton and play with the newly openened form via VB. Happily. That is, until I discovered the values I was getting back from VB disagreed with what the form was telling me on screen.
I found out that there were two instances of the form open, one with visible=true and the other visible=false. The first was the one I had opened. The second was opened by aliens, I was forced to conclude. Until I discovered that these two statements produce entirely different results:
1. DoCmd.OpenForm(Form_FormName.Name)
2. DoCmd.OpenForm("FormName")
I had chosen method 1 so that if I changed my form name, I wouldn't have to change my code. Supposedly safer. I never had this problem when I was using .MDBs! However, in a .ADP if you call
Form_FormName.Name
and the form is not open, the project automatically opens a hidden instance to query the property (.Name) and doesn't close it. Hence method 1 opens the form twice. When you query the form in VB, you're actually talking to the initially opened, but hidden, instance of the form.
I guess I was being too tricky for myself!!!
Hope this helps someone somewhere or is interesting to same.
Cheers,
HappyCoda