Avatar billede solopolo Nybegynder
10. juni 2002 - 19:46 Der er 5 kommentarer og
1 løsning

Autofill last value from the same field

Does anyone know how can I set a field's default value in table properties or in a form properties so that while entering new records it retrieves the value from the last record? But it should be editable, that is, even though I get the value from the last record but can enter a new value, if required.
Please help me!!!! Thanks.
SoloPOLO!
10. juni 2002 - 20:03 #1
Hi Solopolo,

On the forms OnCurrent-event, you place this code:

Private Sub Form_Current()
  Dim rs As DAO.Recordset
  If Me.NewRecord Then
      Set rs = Me.RecordsetClone
      rs.MoveLast
      Me![YourField].DefaultValue = "'" & rs![YourField] & "'"
      rs.Close
  End If
End Sub
10. juni 2002 - 20:04 #2
The code requires a reference to Microsoft DAO 3.x Object Library, if you don't use Access 97.
Avatar billede fdata Forsker
10. juni 2002 - 20:32 #3
As we say in Accessian: Duplicates not allowed.
Isn't this question 222772?
Avatar billede solopolo Nybegynder
10. juni 2002 - 20:34 #4
I've been having trouble in searching because of lack of danish language skills. Sorry
Avatar billede fdata Forsker
10. juni 2002 - 20:37 #5
No problemos. Just answer your own question and accept it.
(Kommentar=Comment, Svar=Answer)
Avatar billede solopolo Nybegynder
10. juni 2002 - 20:41 #6
See pato's solution to question # 222772
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Dyk ned i databasernes verden på et af vores praksisnære Access-kurser

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester

IT-JOB