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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't save my work with a button 1

Status
Not open for further replies.
Apr 26, 2004
87
US
Here is a code that i have..this is an update button that is supposed to save the work on the form and open a new one.

Private Sub Command4_Click()
On Error GoTo Err_Command4_CLick

If IsNull(CompanyName) Then
MsgBox "Company Name is blank, please click BACK Button"
Exit Sub
End If


DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

DoCmd.Close

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "New_Proposal"
DoCmd.OpenForm stDocName, , , stLinkCriteria


Exit_Command4_click:
Exit Sub

Err_Command4_CLick:
MsgBox Err.Description
Resume Exit_Command4_click
End Sub


After the save it is supposed to open the form again to display a fresh blank record? Instead when i press the button it closes the form then gives me the following error.

The table 'Customers' is already opened exclusively by another user, or it is already open through the user interface and cannot be manipulated programmatically.??

anyknow know what this means? or how to fix it?

MCSE 2K - MCSA 2K - NET+ - A+

Paul..
 
How are ya sidetracked . . . . .

Try this:
Code:
[blue]Private Sub Command4_Click()

On Error GoTo Err_Command4_CLick

   If IsNull(CompanyName) Then
      MsgBox "Company Name is blank, please click BACK Button"
   Else
      DoCmd.DoMenuItemacFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
      [purple][b]DoCmd.GoToRecord acDataForm, "New_Proposal", acNewRec[/b][/purple] [green]'New Record![/green]
   End If

Exit_Command4_click:
Exit Sub

Err_Command4_CLick:
MsgBox Err.Description
Resume Exit_Command4_click

End Sub
[/blue]

Calvin.gif
See Ya! . . . . . .
 
sidetracked . . . . .

There are newer commands you should use instead. The code modifies to the following:
Code:
[blue]Private Sub Command4_Click()

On Error GoTo Err_Command4_CLick

   If IsNull(CompanyName) Then
      MsgBox "Company Name is blank, please click BACK Button"
   Else
      [purple][b]DoCmd.RunCommand acCmdSaveRecord
      DoCmd.RunCommand acCmdRecordsGoToNew[/b][/purple]
   End If

Exit_Command4_click:
Exit Sub

Err_Command4_CLick:
MsgBox Err.Description
Resume Exit_Command4_click

End Sub[/blue]

Calvin.gif
See Ya! . . . . . .
 
Thank you sir! works great..

MCSE 2K - MCSA 2K - NET+ - A+

Paul..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top