Solved

form - fields don't refresh

Posted on 2013-10-31
6
320 Views
Last Modified: 2013-10-31
Dear experts -
I have a button, when it's pressed it does a number of calculations and updates a number of fields on the form. These fields are all bound. (It updates them to allowable values, most of them are text fields.)
The button is not saving the record - the user still has to manually adjust the record.
However, after hitting the button, the fields don't visually refresh - however, the values are correctly updated, since when i put the cursor in any of the fields it then shows the correct, updated value.
I don't think I want to requery the form, since that would restore values to the last-saved condition; I tried form.refresh, but this is causing the record to save first, which I don't want.
any ideas?
Thanks -
0
Comment
Question by:terpsichore
  • 4
  • 2
6 Comments
 
LVL 57
ID: 39613810
Issue a Me.Repaint.

Jim.
0
 

Author Comment

by:terpsichore
ID: 39613833
that doesn't work for some reason
0
 
LVL 57

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 500 total points
ID: 39613848
Need more detail on the setup and what your doing.   You've covered all three possibilities already:

Repaint - Forces a repaint and re-calculate of all controls based on existing data.
Refresh - Gets fresh data for the existing records.
Requery - Dumps all records and gets a new recordset - This picks up new records where a refresh will not.

Jim.
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

Author Comment

by:terpsichore
ID: 39613864
1. the form is a simple form based on a single table.
2. I have a 'populate' button, with the code pasted below which fires on the Click event of the button. This all executes correctly, and exits the procedure with the right values for each of those controls.
3. As I said above, when I click on an individual control, it appears with the new, updated value.

Thanks -

Private Sub cmdPopulate_Click()
'If Me.chkPTDifferentRemitAddress = True this button is disabled


If MsgBox("You are about to populate ALL PT fields based on the current data - are you sure?" & vbCrLf & vbCrLf & "(You will be able to manually edit data before saving; you can also re-edit the PT data at any time before an export)." & vbCrLf & vbCrLf & "NOTE: the program will SKIP any fields that exceed the target field length - you will need to edit these manually.", vbYesNo) = vbNo Then
    Exit Sub
End If


'populate PTvendorname
If Me.txtlen_companyname > 0 Then
    If Me.txtlen_companyname <= Me.txtLimit_PTVendorName Then
        Me.PTVendorName = Me.txtCompanyName
    End If
Else
    If Me.txtlen_fullname > 0 And Me.txtlen_fullname <= Me.txtLimit_PTVendorName Then
        Me.PTVendorName = Me.txtForename & " " & Me.txtSurname
    End If
End If

'populate PTcontact
If Me.txtlen_companyname = 0 Then
    'do not populate! name was already used to populate ptvendorname
Else
    If Me.txtlen_fullname > 0 And Me.txtlen_fullname <= Me.txtLimit_PTContact Then
        Me.PTContact = Me.txtForename & " " & Me.txtSurname
    End If
End If

'populate PTaddress1
If Me.txtlen_address1 > 0 And Me.txtlen_address1 <= Me.txtLimit_PTAddress1 Then
    Me.PTAddress1 = Me.txtAddress1
End If

'populate PTaddress2
If Me.txtlen_address2 > 0 And Me.txtlen_address2 <= Me.txtLimit_PTAddress2 Then
    Me.PTAddress2 = Me.txtAddress2
End If

'populate PTcity
If Me.txtlen_city > 0 And Me.txtlen_city <= Me.txtLimit_PTCity Then
    Me.PTCity = Me.txtCity
End If

'populate PTstate
If Me.txtlen_state > 0 And Me.txtlen_state <= Me.txtLimit_PTSpecialState Then
    Me.PTSpecialState = Me.txtState
End If

'populate PTPostalCode
If Me.txtlen_postalcode > 0 And Me.txtlen_postalcode <= Me.txtLimit_PTPostalCode Then
    Me.PTPostalCode = Me.txtPostalCode
End If

'populate PTCountry_ID
Me.cboPTCountry_ID = Me.cboCountry_ID

Me.Form.Repaint


End Sub

Open in new window

0
 

Author Comment

by:terpsichore
ID: 39613919
I've requested that this question be closed as follows:

Accepted answer: 0 points for terpsichore's comment #a39613833

for the following reason:

actually - your repaint solution worked. I realize the problem was (stupidly) I was updated the field values and not the text fields. thank you!
0
 

Author Closing Comment

by:terpsichore
ID: 39613920
sorry - i meant to choose Jim's response here. This ended up being the solution.
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
HasData 9 37
Password on a button in Access 2013 7 35
Open a Specific Record With a Specific Tab Page 5 31
Conditional lock of one field in  datasheet 9 21
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now