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 <> "" Then
DoCmd.GoToRecord , , acNewRec
'must give focus to form and then close it.
'Form_AddManufacturer.SetFocus
DoCmd.Close acForm, "Form_AddManufacturer"
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!
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 <> "" Then
DoCmd.GoToRecord , , acNewRec
'must give focus to form and then close it.
'Form_AddManufacturer.SetFocus
DoCmd.Close acForm, "Form_AddManufacturer"
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!