|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Get Data From Previous
Hi,
I'm trying to get a 'get data from previous record' function to work, but, well, it doesn't. It's *meant* to get the name of the current control, go back to the previous record, select the control of the same name, copy the data to a variable, go back to the first record, set it to the variable with the data from the prev. record. I get told i have an "Invalid use of 'Null'" Code:
Option Compare Database
Option Explicit
'------------------------------------------------------------
' SetSameAsPrev
'
'------------------------------------------------------------
Function SetSameAsPrev()
On Error GoTo _Error
Dim CurrentControl As String
Let CurrentControl = Screen.ActiveControl.Name
DoCmd.GoToRecord acForm, "Pokédex", acPrevious, 1
Eval ("DoCmd.GoToControl Forms!Pokédex!CurrentControl")
Dim PrevValue As String
Eval ("PrevValue = Forms!Pokédex!CurrentControl.Value")
DoCmd.GoToRecord acForm, "Pokédex", acNext, 1
Eval ("Forms!Pokédex!CurrentControl.Value = PrevValue")
_Exit:
Exit Function
_Error:
MsgBox Error$
Resume _Exit
End Function
Any ideas? I'm using Access 97, if it makes any difference - I've been deciding whether to upgrade, but... nah. - MySQL does all I need; Access is just a convenience. If this doesn't work I'll just use a PHP script. |
|
#2
|
|||
|
|||
|
ROFLMAO, this is one of those times you should use Google FIRST. Turns out there's a handy keyboard shortcut that does just this - CTRL+'
![]() |
|
#3
|
|||
|
|||
|
I'm not quite sure what Akdor's referring to. Anyways, maybe I'm missing something with your code, but I think I know where you're getting an error from with it. Does this code execute for each record as that record is accessed? If so, then when you access the first record, there is NO previous record to go to. Maybe adding a check for BOF.
|
![]() |
| Viewing: Dev Articles Community Forums > Databases > Microsoft Access Development > Get Data From Previous |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|