Hi. I use two different pieces of code to manipulate a recordsource for
a form. The first one sets the recordsource to null when the form loads.
The second is supposed to display the corresponding record when a name
is selected from a combobox.
---Code start----
Private Sub Form_Load()
If Not Me.FilterOn Then 'If filter is on, then this form was opened from
another form by double cicking on a contact, so don't null the recordset
StrSql = "select * from Contacts where False" 'else null the
recordset so that form is blank at startup
Form.RecordSource = StrSql 'until goto box has selected
something
Else
cbxSelectContact.Enabled = False
End If
End Sub
---Code End-----
----Code Start----
Private Sub cbxSelectContact_AfterUpdate()
Form.RecordSource = "Contacts"
'Bind the form to the contacts table
'find the record in the table that matches the control
'display it in the form.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[ContactID] = " & Str(Nz(Me![cbxSelectContact],
0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
If UCase(streditmode) = "B" Then 'Browse mode, so lock the
appropriate controls!
If Not LockControlsForBrowse(Me) Then
DoCmd.CancelEvent 'Don't continue to open the form!
FormattedMsgBox ("An error occured while setting up this
form for Browse Mode.@ Please report this error to the Program
Administrator@")
End If
End If
End Sub
-----Code end-----
the second function is the one that doesnt work because when I select a
contact from the dropdwon, their info is not displayed. the thi ng is
tht this works on another form.
thanks
Colin
*** Sent via Developersdex
http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!