Any help would be appreciated docmd.findrecord (1 Viewer)

hully333

Registered User.
Local time
Today, 12:38
Joined
Feb 7, 2008
Messages
18
The following code sits behind an actions form.
Public Sub Command23_Click()
On Error GoTo Err_Command23_Click

Dim stDocName As String
Dim stLinkCriteria As String

asset = DLookup("[asset_name]", "[events]", "[event_id] =" & event_id.Value)

action_desc.Value = action_desc.Value & " " & asset

stDocName = "asset"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Call Forms("asset").findrecord

The dlookup works fine and stores the value in the public variable asset there is a test by adding the value to the action_desc.value.
The rest works well, the open form is ok and the call procedure does indeed fire up the public findrecord function.
Heres the findrecord function code;

Public asset As String

Public Sub findrecord()
If IsNull(asset) = False Then

DoCmd.findrecord ("[asset_name]= " & "'" & asset & "'")
DeviceID.Value = asset

Else

If IsNull(asset) = True Then
DeviceID.Value = "NULL VALUE"

End If
End If
End Sub

Ok The public variable asset has lost its value, and it is neither null or contains anything. Neither of the clauses above work The test field DeviceID.value remains empty but i know that the variable asset had a value a moment ago...weird.
my line DoCmd.findrecord ("[asset_name]= " & "'" & asset & "'") never works either the form loads and it stops on the first record even if i replace the variable with a valid asset name.


The goal is simply grab a value from a form, use a Dlookup to get the ID (all this bit works) and then use it to find a record on another form and display that record.
Recap. I have 2 issues,
My Syntax on the findrecord when using a variable and
The public variable 'asset' losing its value between the 2 public functions

Any help on this would be great.
 
Last edited:

dreamdelerium

Registered User.
Local time
Today, 04:38
Joined
Aug 24, 2007
Messages
88
im not sure if this is it but:
when you pass 'asset' between the functions are is it by refernce or value? im just thinking of how its done in vb. if you pass by refference you lose the value i think
 

Users who are viewing this thread

Top Bottom