Data shown on Form is different from data read from Fields on form

G

Guest

Thank you for any help that this community can provide.

I am using a telephony ActiveX to monitor incoming calls and capture the
Caller ID.
With my form open, when the phone rings the ActiveX delivers the Caller
phone number. Within the same subroutine I then feed the Caller phone number
to a programmatic find and, if the phone number is in the database, the form
retrieves and shows the right record.
So far so good.

At this point, -for additional alert and with the form already on the right
record- I would like to pop up a message, indicating that this particular
client (Client Name, Job Title, etc.) is calling.
To do this, with a MsgBox I then read Client Name, Job Title, etc. from the
form itself.

However the message always returns data relative to the record which was on
the screen PRIOR TO the phone call and different from what is now shown on
the underlying form.
I tried all sorts of events trying to update the data read by the MsgBox but
to no avail (by reading from the fields on the form BeforeUpdate,
AfterUpdate, OnChange, OnCurrent, Requery, GotoRecordNext followed by
GotoRecordPrevious etc. etc.) but to no avail.
It is as if when I read the data to put in the MsgBox, the system reads the
Field.OldValue rather that what is currently shown.

Any suggestion that this estimeed community can provide is highly appreciated.
 
S

strive4peace

Hi Gino,

try
DoEvents

after you move the record pointer in your form

....although it is curous why the MsgBox would not pick up
the current record -- are you referencing form controls or
an underlying query?

Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*
 
G

Guest

Hello Crystal,
I do appreciate your help. Here below is some further explanation.
When the modem detects an incoming call with Caller ID, the following code
executes:
______________________________
Private Sub mTAPIEx_OnCallerID (ByVal m_Call As Object, ByVal CallerName As
String, ByVal CallerIDNumber As String)

'-- Set the focus on the field with phone numbers
txtPhoneNumber.setFocus

'---Search for the record with txtPhoneNumber equal to CallerIDNumber
DoCmd.FindRecord CallerIDNumber, acStart, , acSearchAll, False, acCurrent,
True

'--- The code above retrieves the right record based on CallerIDNumber and I
see it on the form.

'----The code below should read the Company name and Rep Name which I see on
the form and display them in a MsgBox but what happens is that the MsgBox
shows the data on the form PRIOR TO the call. This is unexpected and I am
confused ....

msgbox "Company: " & txtCompanyName & "is on the phone now" & vbcrlf _
& "The Company Rep is: " & txtCompanyRep

End sub
___________________________________
I would like to try the DoEvent you suggest but am not quite sure of how to
use it or about the syntax. Could you kindly point me in the right direction?
Thank you very much.

____________________________________________________
 
S

strive4peace

Hi Gino,

instead of -->
DoCmd.FindRecord CallerIDNumber, acStart, , acSearchAll,
False, acCurrent, True
try this -->

'~~~~~~~~~~~
Me.RecordsetClone.FindFirst _
"PhoneNumber_fieldname = '" _
& CallerIDNumber & "'"

If Not Me.RecordsetClone.NoMatch Then
Me.Bookmark = Me.RecordsetClone.Bookmark
else
'record was not found -- now what?
End If
'~~~~~~~~~~~

if you still have problems...

what is the controlsource of txtCompanyName?

also, you CAN reference the fieldname (instead of
controlname) in your code...

Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*
 
G

Guest

Hi Crystal,
thank you very much for your suggestion!
It did the trick after I found out that events occurring within the
telephony ActiveX tend to remain kind of encapsulated within the ActiveX
procedure, until the procedure is finished.

By finding the record through the recordsetClone and then synchronizing the
bookmark as per your suggestion, the form instead goes into the Form_Current
event before returning to the ActiveX to complete the procedure.
With some additional code in the Current_Event I am now able to pop-up the
message with the right information.

With my previous standard FindRecord, the form actually found the correct
record - and I could see it- but somehow (and I am guessing here...), without
refreshing the memory from which the MsgBox was pulling the Caller details.

Thank you again for all your help.
Gino
~~~~~~~~~~~~~~~~~~~
 
S

strive4peace

you're welcome, Gino ;) happy to help

Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*
 

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