Subform On Click

  • Thread starter Rumie Kohl via AccessMonster.com
  • Start date
R

Rumie Kohl via AccessMonster.com

I have a main form with a subform on it. The main form has text box fields
with a drop-down for vendor name.

The subform is datasheet format. The subform has four fields on it. The
only reason I'm using the subform in datasheet is to show the User all the
records for this vendor instead of clicking thru the mainform. Also the
user can sort the datasheet, whereas the mainform is one at a time.

Once the user has sorted the records on the datasheet and want to see the
full record populate on the main form, I have the following click procured,
but it's not working.

Can anyone help me with this?


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

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

End Sub

Thanks,
Romie
 
G

Guest

I use that, mybe it can help you

You can use this code
create a button called Search, and enter this code in the on click event.
create a text box called SearchText where the input enered by the user.
create a text box called FieldType where the type of the field will be input
its important for the search
create a text box called GoBackTo where the name of the field in the table
will be entered.
fields GoBackTo, FieldType are visible false.
on the got focus in each field in the sub form assign the value to the text
boxes: FieldType and GoBackTo

pressing the button again will take you to the next record (I hope it will
work)

Private Sub Search_Click()
On Error GoTo Search_Click_err
Dim res
Dim FormMark
Dim Table_fast As Recordset
Dim Crit_fast As String

' check the value enterd
If IsNull(Me![SubFormName].SourceObject) Or IsNull(Me!SearchText) Then
GoTo Exit_Search_Click
End If

Set Table_fast = Me![PR_BrowseMainSub].Form.RecordsetClone

If Not (Me!SearchText = "") Then
Select Case Me![FieldType]
Case "Str"
res = ChkRemark(CStr(Me!SearchText))
Crit_fast = [GoBackTo] & " Like '*" & res & "*'"
Case "Num"
Crit_fast = [GoBackTo] & " = " & Me!SearchText
Case "Date"
res = ChkSpace(CStr(Me!SearchText))
res = " #" & Format(CVDate(res), "mm/dd/yyyy") & "#"
Crit_fast = [GoBackTo] & " Like " & res
End Select
Else
GoTo Exit_Search_Click
End If

If CountSearch = 0 Then
Table_fast.FindFirst Crit_fast
CountSearch = 1
Else
Table_fast.FindNext Crit_fast
End If

If Not Table_fast.NoMatch Then
FormMark = Table_fast.Bookmark
Me![PR_BrowseMainSub].Form.Bookmark = FormMark
End If

Exit_Search_Click:
Exit Sub

Search_Click_err:
MsgBox Error
Resume Exit_Search_Click
Resume
Exit Sub

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top