cbo from main form to reference control on subform

magster06

Registered User.
Local time
Yesterday, 23:24
Joined
Sep 22, 2012
Messages
235
Hi guys,

Ok, this is what I have:

I have setup my main form with 2 subforms to mimic a split form; this works fine.

To search for a record, I am using a cbo on the main form which I would like the user to select from. Once selected, then this will populate the first subform.

This is the code I have for the cbo:

Code:
Dim intAnswer As Integer
 
     If IsNull(Me!cboCaseNoCFDWit) Then Exit Sub
    With Me!sfFocus.Form.RecordsetClone
      .FindFirst "Me!sfFocus.Form!CaseNumber = """ & Me!cboCaseNoCFDWit & """"
      If Not .NoMatch Then
         If Me.Dirty Then Me.Dirty = False
         Me!sfFocus.Form.Bookmark = .Bookmark
      Else
         intAnswer = MsgBox("The Case Number was not found! Do you wish to add a Focus to PSU Case Number """ & Me!cboCaseNoCFDWit & """ ", vbYesNo + vbInformation, "Case Number Not Found")
            If intAnswer = vbYes Then
                DoCmd.GoToRecord , , acNewRec
                txtCaseNumber = "" & Me!cboCaseNoCFDWit & ""
            Else
                Exit Sub
            End If
 
      End If
    End With

I get an error at the .findfirst; states that the Microsoft Engine does not recogize Me!sfFocus.Form!CaseNumber

And the reason I am not using a regular split form is because I cannot, for the life of me, get the form to the size that I want. The splitform works great with the code above (a few changes to it of course), but the bottom of the splitform (datasheet) is too long and I cannot shorten it.
 
Man, I must not have had enough coffee, lol.

I just realized that I was trying to reference a control and I really needed to reference the table, arrrgh!

Sorry to waste a thread guys!
 
Ok, I guess I dont have it work correctly, darn.

I did get the error to stop, but now whatever record I click on in the cbo I get the message box telling me that the record is not there, which it is.

Would it have to do with the cbo reference?

Code:
.FindFirst "CaseNumber = """ & Me!cboCaseNoCFDWit & """"

OR is there a way to accomplish the same thing (mimic split form) with just one subform and the main form?

Also, I just found that if I changed the splitform property "auto resize" to "no", then I can get it to the size I want.

I still would like to know what I am doing wrong in the above code though.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom