×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Not finding the form that's open. Umbane?

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?

(OP)
Oh yeah, this is code for a button to open a form from another form.  When this happens either it finds info that is already there, or it fills in the company Id for you so you don't have to do it.

just in case anyone was wondering.

Thanks lovely people that help me!

RE: Not finding the form that's open. Umbane?

If you are opening the address form from the business information form, try replacing Forms![BusinessInformation]![Company_ID] with me.company_id

Mike Rohde
rohdem@marshallengines.com

RE: Not finding the form that's open. Umbane?

Also, is company_id declared as number or text?

Mike Rohde
rohdem@marshallengines.com

RE: Not finding the form that's open. Umbane?

(OP)
I have been remiss in checking here! Darn! You probably aren't looking anymore, but the ID is text.

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?

I'm a little confused as to how you are determining if information already exists.....you have a dlookup statement in your if clause, but there is no comparison, i.e.

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?

Thoughts...

businessaddress should not be in brackets as it is a table vs a field.

Or am I wrong???


Mary

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close