user2204315
user2204315

Reputation:

Text Box on form must pick up data from another form

I have two forms: frmReceipts and frmDiffs. frmReceipts has an unbound control that shows the result of this function:

Public Function RecDiffs() As Double

RecDiffs = Forms!frmDiffs.Text17

End Function

At the moment the value of Text17 is 54.00 but when frmReceipts opens it shows the value 0.00 on control Text41. I can correct this by clicking a command button that runs Me.Form.Refresh

Refresh does not work (i.e. Text17 continues to show 0.00) if Refresh runs On Load, On Open, or On Activate. It only seems to work by clicking the command button. Ideally I'd like the correct value to show in Text17 simply when the form opens. Also, If I put frmReceipts into Design mode then back into Form View, Text17 then shows the correct data.

Upvotes: 0

Views: 60

Answers (3)

user2204315
user2204315

Reputation:

Stumbled across the answer: frmDiffs sorts records by 'ClientName'. Deleting that procedure solved the problem entirely. It might have been caused by the fact that at the moment there is only one record. Cisco had suggested I upload the database. I was deleting certain data prior to upload. This caused an error message relating to the OrderBy procedure, which I then deleted.

Upvotes: 0

Sixthsense
Sixthsense

Reputation: 1975

Use

.Requery

Instead of refresh.

Upvotes: 1

Cisco
Cisco

Reputation: 251

define the Control Source of the unbound control in frmReceipts equal to

Control Source: =[Forms]![Form2]![Text0]

It will show the correct value.

You can also define your control as

enabled: false
locked: True

I checked your code (MS Access 2013) and it runs well, but if Text17 contains a string, you can have a conversion problem in your function.

Upvotes: 0

Related Questions