Update a textbox

D

Damien McBain

This should be easy but she no working.

2 forms: frmDateEntry and frmCustLookup

On frmDataEntry there are many controls, in particular, a bound text box
called "ICust" and an unbound textbox called Lookup.

The Lookup textbox has an afterupdate event which opens the other form
(frmCustLookup) and filters it based on the contents of Lookup.
frmCustLookup returns a list of customers matching the string in "Lookup".
All this works perfectly.

The on double click event of the text boxes on frmCustLookup is:

Private Sub CustName_DblClick(Cancel As Integer)
On Error GoTo AwwwShit
'===============================

Dim daNumba
daNumba = CustNo
DoCmd.Close
Forms!frmDataEntry!ICust.SetFocus
ICust = daNumba
'MsgBox daNumba

'===============================
gtfo:
Exit Sub
AwwwShit:
MsgBox Err.Description, , "F.A.C.T.S."
Resume gtfo
End Sub

It's supposed to populate ICust with the variable "daNumba".
The problem is that ICust is not being updated (even though the variable
daNumba is being set to the right value.

What am I doing wrong?

Damo
 
D

Dirk Goldgar

Damien McBain said:
This should be easy but she no working.

2 forms: frmDateEntry and frmCustLookup

On frmDataEntry there are many controls, in particular, a bound text
box called "ICust" and an unbound textbox called Lookup.

The Lookup textbox has an afterupdate event which opens the other form
(frmCustLookup) and filters it based on the contents of Lookup.
frmCustLookup returns a list of customers matching the string in
"Lookup". All this works perfectly.

The on double click event of the text boxes on frmCustLookup is:

Private Sub CustName_DblClick(Cancel As Integer)
On Error GoTo AwwwShit
'===============================

Dim daNumba
daNumba = CustNo
DoCmd.Close
Forms!frmDataEntry!ICust.SetFocus
ICust = daNumba
'MsgBox daNumba

'===============================
gtfo:
Exit Sub
AwwwShit:
MsgBox Err.Description, , "F.A.C.T.S."
Resume gtfo
End Sub

It's supposed to populate ICust with the variable "daNumba".
The problem is that ICust is not being updated (even though the
variable daNumba is being set to the right value.

What am I doing wrong?

Damo

Since ICust is not on the form where this code is running, you need to
refer to it *on the form that contains it*. Instead of this:
ICust = daNumba

write this:

Forms!frmDataEntry!ICust = daNumba

Or, to be marginally more efficient (by not resolving the form/control
reference twice) ...

With Forms!frmDataEntry!ICust
.SetFocus
.Value = daNumba
End With
 
M

M.L. Sco Scofield

Love your error handler label name. :)

Wish I could use it in class and/or production apps.

Just not P.C. :-(

Sco
 
D

Damien McBain

M.L. Sco Scofield said:
Love your error handler label name. :)

Wish I could use it in class and/or production apps.

Just not P.C. :-(

This *is* a production ap! It's been sanitised too, I used to use:

on error goto ****it
GetTheFuckOut:
exit sub
****it:
msgbox err.description,,"It's broken - Call me and I'll fix it!"
resume GetTheFuckOut

but then I started sharing code with some others at work, some more
sensitive than others.

:)
 

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