473,395 Members | 1,639 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,395 software developers and data experts.

Access with vb

8
Am new to access and VB..I want to open a form from a button click event..can anyone help me to write the code?also while running the query through a butto click i want to display some message and after the completion of running also i want to display a message...can anyone help me out.....
Oct 1 '07 #1
3 1543
Hi,

To open a form with name <form>, write this code in button_click event:

DoCmd.OpenForm <form>

To display a message in a text box while something is processing:
Create a lable named lblInfo in your form.
In VBA write:
lblInfo.caption = "processing step 1"
Doevents
<some other code that takes some time>
lblInfo.caption = "processing step 2"
Doevents

To display a message box when processing is completed:
ans = MsgBox ("Processing completed",vbOKOnly + vbInformation,"Processing status")
Oct 1 '07 #2
missinglinq
3,532 Expert 2GB
A simple way to start the learning process with Access VBA is to use the built in wizards, such as the command button wizard to accomplish a task, like opening a form, then go into the code and look to see what Access has done. Here's an example of the code the wizard would generate for this task, if the button's name was OpenFormButton and the form to be opened was Form1:
Expand|Select|Wrap|Line Numbers
  1. Private Sub OpenFormButton_Click()
  2. On Error GoTo Err_OpenFormButton_Click
  3.  
  4.     Dim stDocName As String
  5.     Dim stLinkCriteria As String
  6.  
  7.     stDocName = "Form1"
  8.     DoCmd.OpenForm stDocName, , , stLinkCriteria
  9.  
  10. Exit_OpenFormButton_Click:
  11.     Exit Sub
  12.  
  13. Err_OpenFormButton_Click:
  14.     MsgBox Err.Description
  15.     Resume Exit_OpenFormButton_Click            
  16.  
  17. End Sub
  18.  
Now you can see the appropriate code, and even more importantly, you see how error handling is done.

But be aware that Access is sometimes lazy. If you try this and the code looks something like this

Expand|Select|Wrap|Line Numbers
  1. DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
  2.     DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
  3.     DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste Append
  4.  
reseach further for other ways to accomplish your task! Using the Menu items, as this type code does, is not the best practise. This type of code is probably on the way out and may not be supported in future editions of Access.

A note on your message to be displayed while your query is running: many times these messages are thought to be "not displaying" when, in fact, the queries simply run so quickly that the message comes and goes faster than the human eye can process it!

Welcome to TheScripts!

Linq ;0)>
Oct 1 '07 #3
akv006
8
Hi

Ur answer helped me a lot...it was simple and effective

Thanks a lot







Hi,

To open a form with name <form>, write this code in button_click event:

DoCmd.OpenForm <form>

To display a message in a text box while something is processing:
Create a lable named lblInfo in your form.
In VBA write:
lblInfo.caption = "processing step 1"
Doevents
<some other code that takes some time>
lblInfo.caption = "processing step 2"
Doevents

To display a message box when processing is completed:
ans = MsgBox ("Processing completed",vbOKOnly + vbInformation,"Processing status")
Oct 2 '07 #4

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

Similar topics

63
by: Jerome | last post by:
Hi, I'm a bit confused ... when would I rather write an database application using MS Access and Visual Basic and when (and why) would I rather write it using Visual Studio .Net? Is it as easy...
13
by: bill | last post by:
I am trying to convince a client that dotNet is preferable to an Access project (ADP/ADE). This client currently has a large, pure Access MDB solution with 30+ users, which needs to be upgraded....
1
by: Dave | last post by:
Hello NG, Regarding access-declarations and member using-declarations as used to change the access level of an inherited base member... Two things need to be considered when determining an...
13
by: Simon Bailey | last post by:
I am a newcomer to databases and am not sure which DBMS to use. I have a very simplified knowledge of databases overall. I would very much appreciate a (simplifed) message explaining the advantages...
0
by: Frederick Noronha \(FN\) | last post by:
---------- Forwarded message ---------- Solutions to Everyday User Interface and Programming Problems O'Reilly Releases "Access Cookbook, Second Edition" Sebastopol, CA--Neither reference book...
20
by: Olav.NET | last post by:
I am a .NET/C++ developer who is supposed to do some work with Access. I do not know much about it except for the DB part. Questions: *1* I am looking for INTENSIVE books to get quickly up to...
64
by: John | last post by:
Hi What future does access have after the release of vs 2005/sql 2005? MS doesn't seem to have done anything major with access lately and presumably hoping that everyone migrates to vs/sql. ...
1
by: com | last post by:
Extreme Web Reports 2005 - Soft30.com The wizard scans the specified MS Access database and records information such as report names, parameters and subqueries. ......
17
by: Mell via AccessMonster.com | last post by:
Is there a way to find out where an application was created from? i.e. - work or home i.e. - if application sits on a (work) server/network, the IT people know the application is sitting...
37
by: jasmith | last post by:
How will Access fair in a year? Two years? .... The new version of Access seems to service non programmers as a wizard interface to quickly create databases via a fancy wizard. Furthermore, why...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.