open form from record

eddcole

Registered User.
Local time
Today, 16:41
Joined
Jan 5, 2016
Messages
18
Hi there

I have created a database that is populated from 4 different forms. The database knows which form created what record from a field auto created.

I have put a search together in a split form to locate records, now how can I open the record to the correct form it was filled in on hopefully by double clicking the record.

I have not much experience I the coding so please explain if code is required

Thank you in advance
 
there is a field that is auto populated with the form name
 
if there is an pk key (i supposed ID) in your table, you can dLookup that table for the correct form name, then open/set focus on that form.
supposed you elected to use the double_click event of your control:


Function IsFormLoaded(ByVal strFormName As String) As Boolean
Dim oAccessObject As AccessObject
Set oAccessObject = CurrentProject.AllForms(strFormName)
IsFormLoaded = False
If oAccessObject.IsLoaded Then
If oAccessObject.CurrentView <> acCurViewDesign Then IsFormLoaded = True
End If
Set oAccessObject = Nothing
End Function


private sub controlname_dblclick()

dim frmName as string

frmName = Dlookup("[auto populated]", "tablename", "ID = " & ME.id) & ""
if frmName <> "" then
if isformloaded(frmname) then
docmd.close acForm, frmName, acSaveNo
end if
docmd.openform frmName,,, "[ID] = " & ME.ID
end if
end sub

the public function IsFormLoaded should be put in a module.
 
If the field is on the form, simply

DoCmd.OpenForm Me.TextboxName

Adding the argument in the link.
 

Users who are viewing this thread

Back
Top Bottom