Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 2 / April 2008

Tip: Looking for answers? Try searching our database.

Can I eliminate the Yes/No Append message box?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
magmike - 29 Apr 2008 23:37 GMT
I have a button that adds a new record to a table (see code below). Of
course, before doing it, a message box pops up telling me I am about
to append 1 row(s) with a yes no button.

Is there a way to code the button, so that the Yes/No message box does
not happen or to automatically send Yes to that function?

Thanks in advance!

the button code:
Private Sub AddStatus_Click()
Dim stSQL As String
Dim stControl As String
stSQL = "INSERT into Status (StatusCompany, StatusCode) values ([ID],
[StatusCodeTemp])"
stControl = "StatusCodeTemp"
DoCmd.RunSQL stSQL
DoCmd.GoToControl stControl
DoCmd.RunCommand acCmdRefresh
End Sub

magmike
Douglas J. Steele - 30 Apr 2008 00:57 GMT
The best way is

Private Sub AddStatus_Click()
Dim stSQL As String
Dim stControl As String

 stSQL = "INSERT into Status (StatusCompany, StatusCode) values ([ID],
[StatusCodeTemp])"
 stControl = "StatusCodeTemp"

 CurrentDb.Execute stSQL, dbFailOnError
 Me.Controls(stControl).SetFocus
 DoCmd.RunCommand acCmdRefresh

End Sub

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)

>I have a button that adds a new record to a table (see code below). Of
> course, before doing it, a message box pops up telling me I am about
[quoted text clipped - 18 lines]
>
> magmike
magmike - 30 Apr 2008 16:34 GMT
On Apr 29, 6:57 pm, "Douglas J. Steele"
<NOSPAM_djsteele@NOSPAM_canada.com> wrote:
> The best way is
>
[quoted text clipped - 40 lines]
>
> - Show quoted text -

When I used the new code, I got the following error:

Run-time error '3061':

Too few perameters. Expected 2.

When  I click on debug, the CurrentDb line is highlighted.

What are we missing?
Douglas J. Steele - 30 Apr 2008 20:02 GMT
Sorry, I didn't look closely enough at your SQL.

What are [ID] and [StatusCodeTemp]?

To get their values (rather than their names) into the SQL statement, you
need something like:

stSQL = "INSERT into Status (StatusCompany, StatusCode) " & _
 "Values (" & [ID] & ", '" & [StatusCodeTemp] & "')"

There, I'm assuming StatusCompany is a numeric field, and StatusCode is a
text field. Check the quotes in the Values line. Exagerated for clarity,
that's

 "Values ( " & [ID] & ", ' " & [StatusCodeTemp] & " ' ) "

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

> When I used the new code, I got the following error:
>
[quoted text clipped - 5 lines]
>
> What are we missing?

On Apr 29, 6:57 pm, "Douglas J. Steele"
<NOSPAM_djsteele@NOSPAM_canada.com> wrote:
>> The best way is
>>
[quoted text clipped - 11 lines]
>>
>> End Sub
magmike - 30 Apr 2008 20:45 GMT
On Apr 30, 2:02 pm, "Douglas J. Steele"
<NOSPAM_djsteele@NOSPAM_canada.com> wrote:
> Sorry, I didn't look closely enough at your SQL.
>
[quoted text clipped - 46 lines]
>
> - Show quoted text -

That did it. Actually, though, both fields are number fields.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.