Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

closing a form using a button that does soemthing else as well

Status
Not open for further replies.

drewdaman

Programmer
Aug 5, 2003
302
0
0
CA
Hi there, i'm new to this.

was wondering if someone could help me out.

i'm trying to make an application in ms acces. What i want to do is this:
I have already added a button called "Done" on a form. I want this button to add something to a table (which i managed to do) and then close the form. I can't seem to get it to close the form. I tried DoCmd.Close adn a few other things. but it says something about not having focus. I tried changing the focus to the form, but it still doesn't work. WOuld be awesome if someone could help me out with this!! Would really appreciate it.

Here is teh code i have so far:

Private Sub cmdDone_Click()
On Error GoTo Err_cmdDone_Click

'Check if there is text in the text box
'if so add the record and close the form
'if not then just exit

If Manufacturer.Text <> &quot;&quot; Then
DoCmd.GoToRecord , , acNewRec

'must give focus to form and then close it.
'Form_AddManufacturer.SetFocus
DoCmd.Close acForm, &quot;Form_AddManufacturer&quot;
Else: DoCmd.Close
End If

Exit_cmdDone_Click:
Exit Sub

Err_cmdDone_Click:
MsgBox Err.Description
Resume Exit_cmdDone_Click

End Sub


New to vb... C++ user.. thanks a lot!
 
What do you mean exactly?

Try:

me.close
me.dispose

If that still plays up, then try displaying the message in a status bar or text box. I would also be inclined to use Try-Catch-Finally blocks in my code, as they are cleaner to read and follow.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top