Box with chosen value stays in the next record

Pusher

BEOGRAD Put
Local time
Today, 23:34
Joined
May 25, 2011
Messages
230
Hello friends,
How can i make a box remember the value from the last record and fill the box automatically when i go to the next

Thanks a lot
 
The Allen Browne article JBB pointed you to gives you a couple of methods to do this, but FYI, Access also provides a fairly easy way. When in the next Record's Control for the Field in question, simply use the keyboard shortcut

<Ctrl> + <'>

This is a good way to do it if you sometimes but not always want to do this.

Linq ;0)>
 
This works but when i open the form - not when i go to the next record - how to fix this?
 
John Big Booty's solution is working, but when i go to the next record it does not work. When i close the form and open it again it works. It gets the last record form the table.
 
In your form, you can use the AfterUpdate event of the control holding your data to set the DefaultValue for the Field. From that time forward, until you either manually change the data or close your form, the data will be entered automatically in each new record.
Code:
Private Sub YourControlName_AfterUpdate()
   Me.YourControlName.DefaultValue = """" & Me.YourControlName.Value & """"
End Sub
Linq ;0)>
 
In your form, you can use the AfterUpdate event of the control holding your data to set the DefaultValue for the Field. From that time forward, until you either manually change the data or close your form, the data will be entered automatically in each new record.
Code:
Private Sub YourControlName_AfterUpdate()
   Me.YourControlName.DefaultValue = """" & Me.YourControlName.Value & """"
End Sub
Linq ;0)>

Thanks this is working :) but how can i make it work for dates as well. It works for text in the box but when i put the box with the date it does not.
 
Just re-checked and it works fine for me with Text, Integer and Date Fields! I seem to remember, from the dark recesses of my mind, someone reporting that they had to enter the code and save the Form before running it, in order for it to work.

But you can try a Date/Time Field specific syntax and see if it works for you
Code:
Private Sub YourDateFieldlName_AfterUpdate()
 YourDateFieldlName.DefaultValue = "#" & Me.YourDateFieldlName.Value & "#"
End Sub
Linq ;0)>
 
Not working ... :( maybe b/c i made a button for today's date...

Code:
Private Sub DanasnjiDatum_Click()
On Error GoTo Err_DanasnjiDatum_Click
    
    Me.DATUM_IZVESTAJA = Date

    DoCmd.RunCommand acCmdApplyFilterSort

Exit_DanasnjiDatum_Click:
    Exit Sub

Err_DanasnjiDatum_Click:
    MsgBox Err.Description
    Resume Exit_DanasnjiDatum_Click
    
End Sub
And this is the code for afterupdate
Code:
Private Sub DATUM_IZVESTAJA_AfterUpdate()

    Me.DATUM_IZVESTAJA.DefaultValue = """" & Me.DATUM_IZVESTAJA.Value & """"

End Sub
I also tryed with "#"
 
That's because most events associated with a Control, including the AfterUpdate event, only fire if the value is physically entered/selected! To use the AfterUpdate when entering the Control's Value via code, you'd have to explicitly Call it. So, instead of

Code:
Me.DATUM_IZVESTAJA = Date

use

Code:
Me.DATUM_IZVESTAJA = Date
Call DATUM_IZVESTAJA_AfterUpdate
Linq ;0)>
 
Its because of the input mask - when i delete the input mask 99.99.0000;0;_ it works :( - How can i fix this and keep the input mask?
 
That's because most events associated with a Control, including the AfterUpdate event, only fire if the value is physically entered/selected! To use the AfterUpdate when entering the Control's Value via code, you'd have to explicitly Call it. So, instead of

Code:
Me.DATUM_IZVESTAJA = Date
use

Code:
Me.DATUM_IZVESTAJA = Date
Call DATUM_IZVESTAJA_AfterUpdate
Linq ;0)>

This worked thanks a bunch :)
 

Users who are viewing this thread

Back
Top Bottom