Sign Up |  Live StatsLive Stats    Articles 35,345| Comments 159,791| Members 17,821, Newest cdotkhn| Online 209
Home Contact
 (Forgotten?): 
    Sikhism

   
                                                                     Your Banner Here!    

Action Query?

Our Donation Goal : Why Donate? : Donate Today! : Donate Anonymously (ਗੁਪਤ) : Our Family of Supporters
Goal this month: 400 USD, Received: 35 USD (9%)
Please Donate...
Related Topics...
Thread Thread Starter Forum Replies Last Post
Action singhbj Inspirational Stories 9 19-Apr-2009 01:55 AM
Passthrough Query SLOWS Access Query Editor Marc Information Technology 7 28-Jul-2006 08:42 AM
Multiply a Rates Query with a Volumes Query - sounds simple! access user Information Technology 5 28-Jul-2006 08:29 AM
turned off prompt/action queries,still get msg on delete query abs Information Technology 1 28-Jul-2006 08:11 AM


Tags
action, query
Reply Post New Topic In This Forum Stay Connected to Sikhism, Click Here to Register Now!
  #1 (permalink)  
Old 06-Nov-2005, 12:37 PM
Blair's Avatar Blair
Guest
 
Posts: n/a
   
   
Action Query?

  Donate Today!   Email to Friend  Tell a Friend   Show Printable Version  Print   Contact sikhphilosophy.net Administraion for any Suggestions, Ideas, Feedback.  Feedback  

Register to Remove Advertisements
I have a simple question. I have a form with several text boxes and a button
to save the data. When the user clicks the save button the data will be
added to the database. I only want the data entered when the button is
pressed to stop partial info from being put in the database. I am wondering
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/information-technology/6792-action-query.html
the best way to add this data to the database. My prof from my intro class
said to use an action query but the more I research these I get the
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=6792
impression this is incorrect for this situation. My question is in this type
of situation is an action query appropriate for this situation or is there a
more correct way for this? Thanks in advance.....



 
Do share your immediate thoughts or reactions on this issue? We value your views! Login Now! or Sign Up Today! to share your views with us.. Gurfateh!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 06-Nov-2005, 12:37 PM
'69 Camaro's Avatar '69 Camaro
Guest
 
Posts: n/a
   
   
RE: Action Query?

Hi, Blair.

> I only want the data entered when the button is
> pressed to stop partial info from being put in the database. I am wondering
> the best way to add this data to the database.


One may use an unbound form and then use an append query to add the new
record to the table. For example:

Private Sub SaveBtn_Click()

On Error GoTo ErrHandler

CurrentDb().Execute "INSERT INTO tblRequests " & _
"(Qty, ItemDesc, ItemSize, NeedDate) " & _
"VALUES (" & Me!Qty.Value & ", '" & Me!ItemDesc.Value & _
"', " & Me!ItemSize.Value & _
", #" & Me!NeedDate.Value & "#);", dbFailOnError

Exit Sub

ErrHandler:

MsgBox "Error in SaveBtn_Click( ) in " & vbCrLf & _
Me.Name & " form." & vbCrLf & vbCrLf & _
vbCrLf & "Error #" & Err.Number & vbCrLf & Err.Description
Err.Clear

End Sub

.. . . where tblRequests is the table that the new record will be appended
to, Qty is a numerical value, ItemDesc is a text string, ItemSize is another
numerical value, and NeedDate is a Date/Time data type, and the dbFailOnError
argument will allow the user to not be required to confirm the "Do you really
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=6792
want to add this record?" message, without having to turn off the System
Warnings messages.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=6792
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.


"Blair" wrote:

> I have a simple question. I have a form with several text boxes and a button
> to save the data. When the user clicks the save button the data will be
> added to the database. I only want the data entered when the button is
> pressed to stop partial info from being put in the database. I am wondering
> the best way to add this data to the database. My prof from my intro class
> said to use an action query but the more I research these I get the
> impression this is incorrect for this situation. My question is in this type
> of situation is an action query appropriate for this situation or is there a
> more correct way for this? Thanks in advance.....

Reply With Quote
  #3 (permalink)  
Old 06-Nov-2005, 12:37 PM
Larry Linson's Avatar Larry Linson
Guest
 
Posts: n/a
   
   
Re: Action Query?

Access doesn't save the information from a form one control at a time -- you
can intercept and cancel storing the record in the Form's BeforeUpdate
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=6792
event. There are discrete situations which trigger the Record being
written -- when you move to a different Record, when you close the Form,
when code issues a DoCmd.RunCommand acSaveRecord, or when you leave the main
Form to enter a Subform Control.

There are times, I suppose, when it is convenient to use unbound Forms and
code/Queries, but the vast majority of the time, bound Forms are a simpler,
easier, and more straightforward approach, not to mention a lot less work.

Larry Linson
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=6792
Microsoft Access MVP



"Blair" wrote in message
news:6B1AE73E-09A1-463C-B3FC-476D185AF4EF@microsoft.com...
>I have a simple question. I have a form with several text boxes and a
>button
> to save the data. When the user clicks the save button the data will be
> added to the database. I only want the data entered when the button is
> pressed to stop partial info from being put in the database. I am
> wondering
> the best way to add this data to the database. My prof from my intro
> class
> said to use an action query but the more I research these I get the
> impression this is incorrect for this situation. My question is in this
> type
> of situation is an action query appropriate for this situation or is there
> a
> more correct way for this? Thanks in advance.....



Reply With Quote
  #4 (permalink)  
Old 07-Nov-2005, 11:26 AM
Ken Sheridan's Avatar Ken Sheridan
Guest
 
Posts: n/a
   
   
RE: Action Query?

With a bound form you need to prevent the row being committed to the table in
any other way than via the command button, so first declare a Boolean
variable in the form's module's Declarations area:

Dim blnSaveMe as Boolean

In the form's BeforeUpdate event procedure set the return value of the
Cancel argument to True if the variable's value is False and reset the value
to False if it is True:

Cancel = Not blnSaveMe
blnSaveMe = False

In the button's Click event procedure set the value to True and save the
record:

blnSaveMe = True
RunCommand acCmdSaveRecord

There is no real answer as to whether this method is more 'correct' than
using an action query. The use of an unbound form from which the data is
written to the table by means of an SQL ststement can be more appropriate in
some circumstances. You can also use DAO or ADO to update the table. The
following is the code from a simple form's module which does this by
establishing a recordset of people selected by surname and populating the
controls on the form one record at a time. In this case each field IS
updated individually as soon as the user edits a control:

Option Compare Database
Option Explicit

Dim dbs As DAO.Database, rst As DAO.Recordset

Private Sub cboFindContact_AfterUpdate()

Dim strSQL As String

If Not IsNull(Me!cboFindContact) Then
strSQL = "SELECT * FROM Addresses WHERE LastName = " & _
Chr(34) & Me!cboFindContact & Chr(34)

Set rst = dbs.OpenRecordset(strSQL)

With rst
Me!txtFirstName = !FirstName
Me!txtLastName = !LastName
End With
Else
Set rst = Nothing
Me!txtFirstName = Null
Me!txtLastName = Null
End If


End Sub

Private Sub cmdNext_Click()

On Error Resume Next
With rst
.MoveNext
If Err = 0 Then
If .EOF Then .MoveLast
Me!txtFirstName = !FirstName
Me!txtLastName = !LastName
End If
End With

End Sub

Private Sub cmdPrevious_Click()

On Error Resume Next
With rst
.MovePrevious
If Err = 0 Then
If .BOF Then .MoveFirst
Me!txtFirstName = !FirstName
Me!txtLastName = !LastName
End If
End With

End Sub


Private Sub Form_Close()

On Error Resume Next
rst.Close
Set rst = Nothing
Set dbs = Nothing

End Sub

Private Sub Form_Load()

Set dbs = CurrentDb

End Sub


Private Sub txtFirstName_AfterUpdate()

With rst
.Edit
!FirstName = Me!txtFirstName
.Update
End With

End Sub

Private Sub txtLastName_AfterUpdate()
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=6792
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=6792

With rst
.Edit
!LastName = Me!txtLastName
.Update

End With

Me!cboFindContact.Requery

End Sub


"Blair" wrote:

> I have a simple question. I have a form with several text boxes and a button
> to save the data. When the user clicks the save button the data will be
> added to the database. I only want the data entered when the button is
> pressed to stop partial info from being put in the database. I am wondering
> the best way to add this data to the database. My prof from my intro class
> said to use an action query but the more I research these I get the
> impression this is incorrect for this situation. My question is in this type
> of situation is an action query appropriate for this situation or is there a
> more correct way for this? Thanks in advance.....

Reply With Quote
  #5 (permalink)  
Old 08-Nov-2005, 12:52 PM
Blair's Avatar Blair
Guest
 
Posts: n/a
   
   
RE: Action Query?


Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=6792
Thanks to everyone who replied. It was all very helpful. i decided in the
end to use a bound form. My primary key is an autonumber field so I was
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=6792
having difficulties with the unbound form to popluate this field. I didn't
now about canceling the action in the before update event on a form. This
will definetly come in handy! Thanks,
Blair
Reply With Quote
  #6 (permalink)  
Old 16-Nov-2005, 14:50 PM
Andrew R in Canberra's Avatar Andrew R in Canberra
Guest
 
Posts: n/a
   
   
RE: Action Query?

  Donate Today!  


"Blair" wrote:

> I have a simple question. I have a form with several text boxes and a button
> to save the data. When the user clicks the save button the data will be
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=6792
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=6792
> added to the database. I only want the data entered when the button is
> pressed to stop partial info from being put in the database. I am wondering
> the best way to add this data to the database. My prof from my intro class
> said to use an action query but the more I research these I get the
> impression this is incorrect for this situation. My question is in this type
> of situation is an action query appropriate for this situation or is there a
> more correct way for this? Thanks in advance.....


My immediate thought was just to make the fields you need filled in
"required" in the table design - then access won't let you add a record
without those fields being filled - Cheers A
Reply With Quote
   Click Here to Donate Now!

Support Us!
Become a Promoter!
Gurfateh ji, you can become a SPN Promoter by Donating as little as $10 each month. With limited resources & high operational costs, your donations make it possible for us to deliver a quality website and spread the teachings of the Sri Guru Granth Sahib Ji, to serve & uplift humanity. Every contribution counts. Donate Generously. Gurfateh!
ReplyPost New Topic In This Forum Stay Connected to Sikhism, Click Here to Register Now!

Bookmarks


(View-All Members who have read this thread : 0
There are no names to display.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Tools Search
Search:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On

» Gurbani Jukebox
Listen to Gurbani while surfing SPN!
» Active Discussions
sikhism need urgent advice.......
Today 10:03 AM
7 Replies, 87 Views
sikhism Who is "Mohan"?
Today 08:46 AM
22 Replies, 348 Views
sikhism How important is Matha...
Today 08:12 AM
59 Replies, 1,041 Views
sikhism ਨਾਮਾ
Today 06:37 AM
2 Replies, 53 Views
sikhism Sikh Diamonds Video...
Today 04:23 AM
6 Replies, 120 Views
sikhism Are Creator and Creation...
Today 01:30 AM
44 Replies, 2,837 Views
sikhism Herman Hesse,...
Today 00:54 AM
13 Replies, 230 Views
sikhism On a Scale of Most...
Yesterday 21:42 PM
30 Replies, 1,277 Views
sikhism I became victim by...
Yesterday 19:50 PM
0 Replies, 46 Views
sikhism Sikh Books downloads
Yesterday 15:39 PM
2 Replies, 66 Views
sikhism Salok Sheikh Farid ji...
Yesterday 09:35 AM
0 Replies, 47 Views
sikhism In Punjab, three farmers...
Yesterday 05:36 AM
0 Replies, 49 Views
sikhism Supernatural Sikhs, what...
Yesterday 03:45 AM
19 Replies, 416 Views
sikhism Sukhmani Sahib Astpadi...
26-May-2012 22:57 PM
0 Replies, 51 Views
Do You Think You Are...
26-May-2012 09:59 AM
94 Replies, 8,258 Views
» Books You Should Read...
Powered by vBadvanced CMPS v3.2.2

All times are GMT +6.5. The time now is 10:31 AM.
Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.5.2 Copyright © 2004-12, All Rights Reserved. Sikh Philosophy Network


Page generated in 0.45244 seconds with 30 queries