Data not refreshing on form

J

Joy

Hi, A beginner with Access who needs lots of help..
I've a form for users to enter, the fields are not bound to a table.
I would like to create a refresh button so that user can do another
addition. I've tried coding with
Me.Requery on the Refresh button but nothing happens. The current data stays.

I've also tried If Me.Dirty = True Then
Me.Dirty = False
End If

What else should I try?

Thanks Heaps, Joy
 
J

Jeanette Cunningham

Joy,
to use unbound form to do this, you need to create an append query that will
add the data from the controls on the form to the whichever table or tables
you want the data to go into.
Place a save button on the form.
Code the click event of the button to run the append query.

It is much more work to use unbound forms - you have to write code for
everything.
If you use bound forms, there is a lot of built in stuff that automatically
saves records. That makes it quicker and easier to use.
Bound forms are one of the main benefits of using Access.

How did you go with creating that bound form we discussed yesterday - are
there still some things that need fixing to make it work properly?

Jeanette Cunningham
 
J

Jeff Boyce

Joy

If I'm understanding your description, you have a form in which your users
enter data, but that form is not bound to a table.

So, how does Access know "where to stick it?"

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
J

John W. Vinson

Hi, A beginner with Access who needs lots of help..
I've a form for users to enter, the fields are not bound to a table.
I would like to create a refresh button so that user can do another
addition. I've tried coding with
Me.Requery on the Refresh button but nothing happens. The current data stays.

I've also tried If Me.Dirty = True Then
Me.Dirty = False
End If

What else should I try?

Thanks Heaps, Joy

Well, Refresh reloads the data from the table to which the form is bound, and
Dirty applies when a bound control is updated. Neither is meaningful for an
unbound form.

Why are you using an unbound form, at all? What's the point in entering data
that will be displayed on screen while the form is open and never put anywhere
else - or do you have VBA code to take the data from the unbound form and put
it into tables? If so, why do it the hard way rather than simply using a bound
form?

Background please!

John W. Vinson [MVP]
 
J

Joy

Hi Jeff

I made a typo mistake.. the fields are bound. I can't get it to refresh:-(

Thx Joy
 
J

Joy

Hi Jeanette
I just realised I made a typo mistake... I did get the fields to be bound to
a table. All fields are now bound. Sorry!

Hence, my predicament now... its not refreshing :-( with the codes I tried

Thx Joy
 
J

Joy

Hi John

Typo mistake.. the controls are bound to a table.
Just that codes I used for refreshing the form is not working:-(

Thx Joy
 
J

Jeanette Cunningham

Joy,
If you have a save button on your bound form, you will need code to make the
record save.
The code is:

If Me.Dirty Then
Me.Dirty = False
End If

To add the code:
--in design view click the button
--on the properties dialog, fine the event called On Click
--click the button on the right side with the ellipsis (...)
--choose Code Builder
--between the Private Sub and the End Sub
--type the 3 lines of code at the top of this post.

However if you don't use a close button, and just use the redX at top RHS of
form, the data will save automatically.
If this doesn't work for you, post back with details.

Jeanette Cunningham
 
J

John W. Vinson

Hi John

Typo mistake.. the controls are bound to a table.
Just that codes I used for refreshing the form is not working:-(

What's the Recordsource of the form? Please post the SQL.
What are the control sources of the fields you want refreshed?
What's your code?
Why do you need a Refresh at all? It wouldn't *routinely* be necessary.

John W. Vinson [MVP]
 
J

Joy

Hi Jeanette,

Thanks for your help...The record in bound form is saving on to the table.
In the Save cmd button

I used the code you gave below:

If Me.Dirty Then
Me.Dirty = False
End If

But how should I get the form to refresh... so that when I hit the refresh
button, all data showing on form is cleared and I can use it to add
another..or what code should I use... as Me.Refresh does not work either:-(

Thanks Joy
 
J

Joy

Hi Jeanette

I just realised that refreshing according to Help files functions to "
updates the data that already exists in your datasheet or form". What I
really would like (not sure of terminology) is that when I hit the refresh
button on the form, current data disappears, form is clean for a new entry.
Could you pls help me..

Thanks Joy
 
J

Jeanette Cunningham

You need to go to the next new record.
The easy way to do this is to set up the form to show the navigation
buttons.
Open the form in design view,
on the properties dialog,
on the Format tab,
set the property Navigation Buttons to Yes,
save and open in normal view, down the botton of the form will be a set of
button,
to go to a new record, click the button with the star or asterisk on it.
That button will automatically save the current entered data and take you to
the next new record.

Jeanette Cunningham
 
J

Joy

The Navigation buttons are set to yes (its default)
I don't seem to have as an option "save and open in normal view" or "go to a
new record" in the Format tab.. I checked the All tab too...
 
J

Jeanette Cunningham

Save and open in normal view - I really meant - you have finished changing
the form. Close and save it. Now open it in normal view.
Test to see if it works the way you want.

Jeanette Cunningham
 
J

Joy

Strange. When I hit the save button, the form looks the same, no changes took
place. Its only when I move my mouse wheel forward that the form became blank
for me to put in my next entry. I was under the impression that when I hit
the save button, all values in the form will disappear. I am not sure if all
my users have a mouse with a mouse wheel.
 
R

Rick Brandt

Joy said:
Strange. When I hit the save button, the form looks the same, no
changes took place.

Not strange at all as that is exactly what you should expect.
Its only when I move my mouse wheel forward that
the form became blank for me to put in my next entry.

Because the mouse wheel will navigate the form to different records. When you
are on the last record and navigate forward you end up at the new record
position.
I was under the
impression that when I hit the save button, all values in the form
will disappear.

Don't know where you would get that impression. Access forms have never behaved
that way.
I am not sure if all my users have a mouse with a
mouse wheel.


The mouse wheel is not the only way to navigate. Hitting > or >* in the
navigation buttons will do the exact same thing. As will pressing PageDown or
using Records Go To - New on the menu bar.
 
J

Jeanette Cunningham

If you want that behaviour,
change the code behind the button to this:

On Error Resume Next
If Me.Dirty = True Then
Me.Dirty = False
End If
DoCmd.GoToRecord acActiveDataObject, , acNewRec


Jeanette Cunningham
 

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