Not finding the form that's open. Umbane?
Not finding the form that's open. Umbane?
(OP)
Private Sub open_address_form_Click()
On Error GoTo Err_open_address_form_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "BusinessAddress"
If DLookup("[company_id]", "[businessaddress]=", "[company_id]=" & Forms![BusinessInformation]![Company_ID]) Then
strlinkcriteria = "[company_id]= forms![BusinessInformation]![company_id]"
DoCmd.OpenForm stDocName, , , strlinkcriteria
DoCmd.Requery
Else
DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenForm stDocName, , , , acFormAdd, , Me![Company_ID]
Exit_open_address_form_Click:
Exit Sub
Err_open_address_form_Click:
MsgBox Err.Description
Resume Exit_open_address_form_Click
End If
End Sub
It's telling me that it can't find the form "BusinessInformation" I have tried everything to change it so the thing will recognize it. The only think I can think, (other than I screwed the code) is that it doesn't like that it's open. But that doesn't make sense! I hope someone can help. I am just doing this all wrong.
RE: Not finding the form that's open. Umbane?
just in case anyone was wondering.
Thanks lovely people that help me!
RE: Not finding the form that's open. Umbane?
Mike Rohde
rohdem@marshallengines.com
RE: Not finding the form that's open. Umbane?
Mike Rohde
rohdem@marshallengines.com
RE: Not finding the form that's open. Umbane?
Here's this. My main problem right now is that it thinks that it can't find the form form that I am opening the other form from. yikes! That was confusing! I hope it made sense....
Private Sub Command66_Click()
Dim strlinkcriteria As String
Dim stdocname As String
stdocname = "businessaddress"
If DLookup("[company id]", "[businessaddress]", "[company id]=" & Forms![businessinformation]![Company ID]) Then
strlinkcriteria = "[company id]=forms![businessinformation]![company id]"
DoCmd.OpenForm stdocname, , , strlinkcriteria
DoCmd.Requery
Else
DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenForm stdocname, , , , acAdd, , Me![Company ID]
End If
End Sub
RE: Not finding the form that's open. Umbane?
if dlookup = something then
do something
end if
Shouldn't you check to see if the dlookup is null??
If Not IsNull(DLookup("[company id]", "[businessaddress]", "[company id]=" & Forms![businessinformation]![Company ID])) Then
strlinkcriteria = "[company id]=forms![businessinformation]![company id]"
DoCmd.OpenForm stdocname, , , strlinkcriteria
DoCmd.Requery
Else
DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenForm stdocname, , , , acAdd, , Me![Company ID]
End If
Mike Rohde
rohdem@marshallengines.com
RE: Not finding the form that's open. Umbane?
businessaddress should not be in brackets as it is a table vs a field.
Or am I wrong???
Mary