Binding a form to a saved table

back to the original question....how do you bind a form?
 
Another option would be to use the Form Wizard (following the instructions).
 
Thank you thank you....missed your instructions on #15! I fixed three other forms also! Great job, I've been struggling for awhile with this problem....you guys are great!!!
 
Thank you thank you....missed your instructions on #15! I fixed three other forms also! Great job, I've been struggling for awhile with this problem....you guys are great!!!

Glad you got it. Sorry it took so long to get to the real issue. (Monday)
 
Too funny....Glad you are all awake, wherever you are and whatever day and time it is!
 
I can tell you what the future looks like :D

Apologies for writing jibberish on your thread Karen :)
 
hey guys, i'm trying to get an unbound form working and i'm getting the "Error 91: Object variable or With block variable not set". it's related to this thread because the error occurs when i try to select a record to go to from a listbox on the unbound form.

the find record code is fine, because once i bind the form, it works without error and as expected. here it is anyway, just for completeness:

(AfterUpdate of listbox)
Code:
     ' Find the record that matches the control.
    Dim rs As Object

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

i'm binding the form in an after update event of a combo box (which casades records for the listbox),

(AfterUpdate of combo (cboSpecies))
Code:
    Me.RecordSource = "SELECT * FROM tblSpecimen_Strain " & _
                      "WHERE SpeciesID = " & Me.cboSpecies & " " & _
                      "ORDER BY tblSpecimen_Strain.Strain;"

    Me.lstStrains.Requery
    Me.txtStrain.ControlSource = "Strain"

which is fine except when i open the form via a button from another form to a specific value in the combobox... that's when the error pops up, because the form is still not bound - that is, i can't figure out how to trigger the afterupdate event of the combo using VBA in another form.

(OnClick of command button from a different form)
Code:
    Dim strDocName As String

    strDocName = "frmClassification"
    DoCmd.OpenForm strDocName
    
    With Forms(strDocName)![fsubClass_Strains]
         .SetFocus
         .Form!cboSpecies.Value = Me.cboSpecies
         .Form!lstStrains.Requery
    End With

i want to prevent double-coding a recordset for the form (i.e., one on combo after update and another on button click from the other form).

i had a similar issue which i fixed with .Recordset.FindFirst, but that was on an already bound form... i can't make the form got to a specific record (even if i know the recordID) when the form isn't bound yet.... or can i?

am i going about this the right way, or am i making it all a little too complex?
 
You mentioned the error pops up because the form is not bound. Bind the form before calling the AfterUpdate routine.

So basically three steps,

1. Check if the RecordSource property of the form is zls
2. If it is, Call Forms(strDocName)![fsubClass_Strains]!cboSpecies_AfterUpdate to bind the form, then run the other code.
3. If it isn't, just run the code.

Remember to make the AfterUpdate routine Public.
 

Users who are viewing this thread

Back
Top Bottom