Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form not work unless I switch to Design view and then back again.

Status
Not open for further replies.

terre

Technical User
Feb 2, 2003
97
AU
I have a form with a combobox (cboGoToContact)
In the combo box After Update I have the following, to select a record for the form, by selecting a value from the combobox

Private Sub cboGoToContact_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[ClientID] = " & Str(Nz(Me![cboGoToContact], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark

Me.subAppointments.Requery
End Sub

When I open the form, the above will not work, unless I switch to Design Mode, and then back to Form view.
Then it works perfectly.
If I close the form, and reopen it, I have to goto Design view again etc.

Any suggestions?
 
Maybe you can try tinkering with adding in Form.Refresh, Form.Requery, or Form.Repaint between the other lines... so it would be...

Code:
Set rs = Me.Recordset.Clone
rs.FindFirst "[ClientID] = " & Str(Nz(Me![cboGoToContact], 0))
Form.Repaint 'or whichever works best here...
If Not rs.EOF Then Me.Bookmark = rs.Bookmark

That's just a stab in the dark, though, honestly.

Another option - different way of doing it - if it will fit in with what trying to do, you could try to filter the form on the values you input rather than using the FindFirst method. I know I've seen some quirks at times with that one, myself.. not all the time, but on some occasions.

So for the filter, you could use something like:
Code:
Form.Filter = "ClientID = " & cboGoToContact
Form.FilterOn = True


"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57
 
My guess would be that your Combobox is corrupted. Although we associate corruption with Forms or entire Databases, Controls can and do become corrupted, as well!

Delete your current Combobox and use the Combobox Wizard, with the third option, to re-create it.

I don't think this is causing your problem, but

Code:
rs.FindFirst "[ClientID] = " & Str(Nz(Me![cboGoToContact], 0))

is not really standard code for this kind of thing.

The only way to get a Null Value, in a Combobox, is for the user to delete a Value that's already been placed there; you cannot use the standard method of scrolling up and down too re-select the 'empty' box that is present before a selection is made.

And I can't imagine any reason to convert the Combobox Value to a String.

If the Combobox returns a Field that is defined as a Number Datatype,

Code:
rs.FindFirst "[ClientID] = " & Me![cboGoToContact]

should work just fine.


The Missinglinq

Richmond, Virginia

The Devil's in the Details!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top