473,387 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Buttons

I need help adding codes to 4 buttons using VBA. I need the buttons to go to a table and delete all the records, load new data, View Summary - which will run the query I wrote, View Table - which will open the table. I figured I needed to design a form with 4 buttons, which I did. The problem is that I have no clue how to code the buttons. Please help!!!
Jun 18 '07 #1
4 1016
JKing
1,206 Expert 1GB
Let's sort this out a little bit.

For loading data: How are you loading it? From a text file? From another database? Are you placing it in an existing table or creating a new one?

View Summary and View Table: Do you want to directly open and display the query / table to the user or are you placing these items in forms?

Delete all records: I'm correct in assuming you want to keep the table structure and just delete the data.
Jun 18 '07 #2
So far, I have been able to get two buttons to run the specified query and load the specified table. this is what I have written so far.

__________to open table
On Error GoTo Err_btnLoad_Click

Dim stDocName As String

stDocName = "Load_New_Data"
DoCmd.OpenTable "Name of My Table", acViewNormal

Exit_btnLoad_Click:
Exit Sub

Err_btnLoad_Click:
MsgBox Err.Description
Resume Exit_btnLoad_Click

_______To run the Query
On Error GoTo Err_btnRun_Query_Click

Dim stDocName As String

stDocName = "Name of Query"
DoCmd.OpenQuery stDocName, acNormal, acEdit

Exit_btnRun_Query_Click:
Exit Sub

Err_btnRun_Query_Click:
MsgBox Err.Description
Resume Exit_btnRun_Query_Click

____to delete all records (not performing the right operation
On Error GoTo Err_btnClear_Click

DoCmd.DeleteObject acTable, "Name of Table"



Exit_btnClear_Click:
Exit Sub

Err_btnClear_Click:
MsgBox Err.Description
Resume Exit_btnClear_Click
Jun 18 '07 #3
JKing
1,206 Expert 1GB
To delete all the records in a table you can do

Expand|Select|Wrap|Line Numbers
  1. Private Sub btnClear_Click()
  2. Docmd.RunSQL("DELETE FROM tblName")
  3. End Sub
  4.  
Jun 18 '07 #4
Thank you. Got all the buttons to work. Thanks a lot.
Jun 18 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Lyn | last post by:
Hi, I hope someone can help. I have a main form which mostly fills the Access window. In the bottom half of this form I have a tab control to display various types of data related to the main...
4
by: Ron | last post by:
I want to create 10 buttons on a form at runtime, the code below is only creating one button labeled 1. Any idea what I am doing wrong? Public Class Form1 Public code(10) As String Public...
3
by: Ron | last post by:
Can anyone help me out? I am trying to add buttons numbered one through 10 at runtime to a form. I think they are getting added but they seem to be getting stacked one on top of each other. so...
2
by: dpazza | last post by:
Hi, I'm creating a quiz on using a form in VB 2005 express. I have four sets of questions and answers (labels and radio buttons) and I change between which set of questions is currently shown on...
4
by: Blasting Cap | last post by:
I have a page that has a number of radio buttons that will be displayed to different access levels of a user who logs in to my website. For instance, if there are a dozen buttons, user1 will see...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.