Filtering on 2 fields in forms

samson

New member
Local time
Today, 16:09
Joined
Sep 7, 2003
Messages
7
I'm trying to filter out telephone calls logged by an isdn line to my customer form, so I can tell how many calls turned into orders.

The code works filtering one 1 field [Phonenumber1], but if I try to filter on the second field aswell [phonenumber2], the results show records including isnull.

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Orders by Customer"

stLinkCriteria = "[PhoneNumber1] or [PhoneNumber2]=" & "'" & Me![telno] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Please help,

Simon
 
Simon,

Having multiple phone # fields makes it a bit tougher.

Code:
stLinkCriteria = "[PhoneNumber1] = '" & Me.[telno] & "' or " & _
                 "[PhoneNumber2] = '" & Me![telno] & "'"

Wayne
 
Wayne,


Sorry for the late reply.


That worked a treat. I was messing with it for hours, trying to split the filters into different events.

I now have another problem with my telephone calls being logged with the name from the customers form.

Once the telephone call is finished, a new record is sent to form [log]. I then want to send the name of the customer to the new record in form [log].

Something like this:

Dim db As Database
Dim rec As Recordset
Set db = CurrentDb()
Set rec = db.OpenRecordset("Log")

If IsLoaded("Orders By Customer") Then
If Forms![Orders By Customer].RecordsetClone.RecordCount > 0 Then
Me.RecordsetClone.Bookmark = Me.Bookmark

' Something wrong with this line below
If Me.RecordsetClone.Count > Me.Bookmark Then

rec.MoveLast
rec.Edit
rec![name] = Me![ContactLastName]
rec![CustomerID] = Me![CustomerID]
rec.Update

DoCmd.Close acForm, "Log"
End If
End If
End If

Thanks alot for the help so far.


Simon
 
Simon,

You need to:

Code:
' rec.MoveLast <-- Don't need
rec.AddNew
rec![name] = Me![ContactLastName]
rec![CustomerID] = Me![CustomerID]
rec.Update

Also, if you surround your code with:
(code)
Some Code ...
(/code)

It will preserve the indentation. Replace the parens with the
square brackets.

Wayne
 
Wayne,

I've not explained it correctly.
Once the call is ended, the Samsung software sends a new record to form [log]. I then want to edit this record with the customer name, etc.
If I do a record count before the new record is logged,then when the record count is added by another record, I can then send the name to that new record.

Me.RecordsetClone.count

' Trying to recognise when a new record is added.
If Me.RecordsetClone.Count > Me.Bookmark Then
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' i thought this might work, but it doesn't
' If Me.RecordsetClone.Count = + 1
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
rec.MoveLast
rec.Edit
rec![name] = Me![ContactLastName]
rec![CustomerID] = Me![CustomerID]
rec.Update


Simon
 

Users who are viewing this thread

Back
Top Bottom