Refresh Form (1 Viewer)

mumbles10

Registered User.
Local time
Today, 02:34
Joined
Feb 18, 2011
Messages
66
Ok... I have two forms... employeeinfo and newemployee. On the employeeinfo form there is a command button that takes you to the new user form where users and can add a new employee. I have a save button on the new employee form. The save button works and updates the appropriate employeeinfo table however, when I click back to the info form, I have to close and reopen the info form to see the new record.

I tried a forms!employeeinfo.refresh at the end of the save button code but it didn't do anything... any thoughts?
 

boblarson

Smeghead
Local time
Yesterday, 23:34
Joined
Jan 12, 2001
Messages
32,059
Refresh doesn't show added or deleted records. You need to use REQUERY.

Forms!employeeinfo.Requery
 

mumbles10

Registered User.
Local time
Today, 02:34
Joined
Feb 18, 2011
Messages
66
Refresh doesn't show added or deleted records. You need to use REQUERY.

Forms!employeeinfo.Requery


Bob,

I put it right at the bottom of the saverecord cmd button in the click event.

It still won't update the form. Only if I close and reopen the form.

it saves to the table fine.
 

boblarson

Smeghead
Local time
Yesterday, 23:34
Joined
Jan 12, 2001
Messages
32,059
Bob,

I put it right at the bottom of the saverecord cmd button in the click event.

It still won't update the form. Only if I close and reopen the form.

it saves to the table fine.

only if you close and reopen WHICH form?

Also, what is the full code in your saverecord cmd button's click event?
 

mumbles10

Registered User.
Local time
Today, 02:34
Joined
Feb 18, 2011
Messages
66
only if you close and reopen WHICH form?

Also, what is the full code in your saverecord cmd button's click event?

frmEmployees...

frmEmployees is the main form. I have a button to add a new user... it pops up another form (frmNewEmployees) which is where the user adds a new employee. that is where the save button is located.

I can't see the new employee in the frmEmployees... only if I close it and re open.
 

boblarson

Smeghead
Local time
Yesterday, 23:34
Joined
Jan 12, 2001
Messages
32,059
frmEmployees...

frmEmployees is the main form. I have a button to add a new user... it pops up another form (frmNewEmployees) which is where the user adds a new employee. that is where the save button is located.

I can't see the new employee in the frmEmployees... only if I close it and re open.
I don't think you read my question too well.

I said -

boblarson said:
what is the full code in your saverecord cmd button's click event
I didn't ask which form it was.
 

mumbles10

Registered User.
Local time
Today, 02:34
Joined
Feb 18, 2011
Messages
66
I don't think you read my question too well.

I said -


I didn't ask which form it was.


Here is the save button code:

Private Sub cmdSaveUSER_Click()
On Error GoTo Err_cmdSaveUSER_Click

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Exit_cmdSaveUSER_Click:
Exit Sub
Err_cmdSaveUSER_Click:
MsgBox Err.Description
Resume Exit_cmdSaveUSER_Click

Forms!frmEmployees.Requery



End Sub
 

boblarson

Smeghead
Local time
Yesterday, 23:34
Joined
Jan 12, 2001
Messages
32,059
Here is the save button code:

Private Sub cmdSaveUSER_Click()
On Error GoTo Err_cmdSaveUSER_Click

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Exit_cmdSaveUSER_Click:
Exit Sub
Err_cmdSaveUSER_Click:
MsgBox Err.Description
Resume Exit_cmdSaveUSER_Click

Forms!frmEmployees.Requery



End Sub
Okay, take a look at your code - there is a very obvious reason why the requery isn't working. Can you see this line:

Resume Exit_cmdSaveUSER_Click

(it is correct but there is something very important to note about it and where your requery is. See if you can figure it out).
 

mumbles10

Registered User.
Local time
Today, 02:34
Joined
Feb 18, 2011
Messages
66
Okay, take a look at your code - there is a very obvious reason why the requery isn't working. Can you see this line:

Resume Exit_cmdSaveUSER_Click

(it is correct but there is something very important to note about it and where your requery is. See if you can figure it out).


Im a moron... thanks... I got it.
 

missinglinq

AWF VIP
Local time
Today, 02:34
Joined
Jun 20, 2003
Messages
6,423
Glad you figured it out! But if I were doing this, I'd simply, in the original, (employeeinfo) form, use this code
Code:
Private Sub Form_Activate()
 Me.Requery
End Sub
If there's ever an occasion to open the newemployee form independently, such as if you had a slew of new employees come in at one time, and the (employeeinfo) form wasn't open, I believe Access would throw a hissy fit, which is to say an error.

Using the original form's OnActivate event will do the job and not have this problem.

Linq ;0)>
 

mumbles10

Registered User.
Local time
Today, 02:34
Joined
Feb 18, 2011
Messages
66
Glad you figured it out! But if I were doing this, I'd simply, in the original, (employeeinfo) form, use this code
Code:
Private Sub Form_Activate()
 Me.Requery
End Sub
If there's ever an occasion to open the newemployee form independently, such as if you had a slew of new employees come in at one time, and the (employeeinfo) form wasn't open, I believe Access would throw a hissy fit, which is to say an error.

Using the original form's OnActivate event will do the job and not have this problem.

Linq ;0)>

Thanks for the suggestion.
 

Users who are viewing this thread

Top Bottom