Closing A Form - VERY BASIC!!!

SteveC24

Registered User.
Local time
Today, 18:19
Joined
Feb 1, 2003
Messages
444
Hi,

I am EXCEPTIONALLY ill-equipt to do anything with VB, all I do in VB is edit bits that are already there, and generally make them worse!!!

Anyway, I tried adding a line of code to this:

Code:
Private Sub go_Click()
On Error GoTo Err_go_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "frm Fish enter"
    
    stLinkCriteria = "[Tank ID]=" & Me![tankname]
    DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_go_Click:
    DoCmd.close acForm, filtanksearch, acSaveNo
    Exit Sub

Err_go_Click:
    MsgBox Err.Description
    Resume Exit_go_Click
    
End Sub


The line I added was:

DoCmd.close acForm, filtanksearch, acSaveNo

Basically, the code above opens a form (frm Fish Enter) and filters it on the field "tankname" in "filtanksearch" with the field "Tank" in the "frm Fish Enter" form.

What I wanted to do, was when it has loaded the second form, for the first one to close.

This post makes no sense, but I hope someone can understand it, as my brain fell out hours ago, and refuses to come back until this is got round!!!

Thanks in advance!
 
try this
Exit_go_Click:
DoCmd.close acForm, "filtanksearch", acSaveNo
 
Thanks, that worked a treat!!!
 
steve on reflection it may be better to move the docmd inside
the error handler procedure


DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.close acForm, "filtanksearch", acSaveNo
Exit_go_Click:
Exit Sub
 
Thanks! :D Do you mind if I ask why? It still works fine, I am just curious.

Thanks again,
 
if an error occurs closing the form then it will be handled by
your error trapping,but not if its outside the error trap
 
Hi SteveClarkson
Wanting to set up the same arrangement so I can see how this works (and learn from it), from your question and bjackson's advice:

Do you have 2 tables then, with 2 forms, filtanksearch and tankname please?

Cheers Kupe
 
Hi,

I started explaining what I had earlier, and gave up! I will attach a database set out like mine is later this evening.

Bye!
 
Perfect, Steve, look forward to it. Many thanks.
 
Hi,

Here is the database for you to try with. It isn't the original, as that is just over 1MB! This is a VERY basic version of it.

I havn't added the code. If you want to get to the original code in the database, it is in the filtanksearch form, on the OK button, in the On_Click event.

HTH,
 

Attachments

Many thanks, Steve. Looks good on the first glance. Look forward to getting into it later. Gratefully
 

Users who are viewing this thread

Back
Top Bottom