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

Visual Basic in MS Access '07?

I just installed MS Office Enterprise on my system today and jumped right in to MS Access. Because I am familiar with Access I had very few problems navigating around. Here is the big question.

Where is the Visual Basic Code???

I made a form and placed an Add Record button on the form. When the user clicks this button, I want to focus to go the the first field on the form. I usually do this with the setfocus command in visual basic. When I clicked on the Visual Basic icon on the ribbon, the Visual Basic window pops up, but there is no code at all except for the command Option Compare Database.

What is going on?

Any help would be appreciated.
Feb 20 '08 #1
16 2783
mshmyob
904 Expert 512MB
You need to activate your PROPERTY sheet. It will appear to the right of your form. If it is not there then RIGHT CLICK on your form and at the bottom you will see the word PROPERTIES in the popup window.

After activating your PROPERTIES sheet you then select the EVENTS tab and then click on the little button that has 3 dots in the ON CLICK event and choose CODE BUILDER.

regards,

I just installed MS Office Enterprise on my system today and jumped right in to MS Access. Because I am familiar with Access I had very few problems navigating around. Here is the big question.

Where is the Visual Basic Code???

I made a form and placed an Add Record button on the form. When the user clicks this button, I want to focus to go the the first field on the form. I usually do this with the setfocus command in visual basic. When I clicked on the Visual Basic icon on the ribbon, the Visual Basic window pops up, but there is no code at all except for the command Option Compare Database.

What is going on?

Any help would be appreciated.
Feb 20 '08 #2
I have no problem getting to the VB Window. When I used the wizard to place a button in Access '03, there was code automatically placed in the VB Window for that control. When I look at the VB Window there is no code at all.

Here is the simple code that I am trying to put in for the cmdAdd button:


Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdAdd_Click()
  2. On Error GoTo Err_cmdAdd_Click
  3.  
  4.     DoCmd.GoToRecord , , acNewRec
  5.     LnameEng.SetFocus
  6.  
  7. exit_cmdAdd_click
  8.     Exit Sub
  9.  
  10. Err_cmdAdd_Click:
  11.     MsgBox Err.Description
  12.     Resume exit_cmdAdd_click
  13.  
  14. End Sub
  15.  
When I type in the doCmd line visual basic acts like I would expect and as soon as I type the two commas, the window pops up and gives me the choices to select such as asNewRec or acFirst or acLast. No problem there.

When I type in the line: LnameEng. I do not get the options I would expect like Setfocus, the only option I get is .value. This would lead me to believe that I had typed the name of the control in wrong, but I double checked the control name and LnameEng is correct and it is a text box and its tab stop value is set to Yes.

The biggest thing here is, I should not have to type in any code for the cmdAdd button because the Wizard should be doing that for me which it is not.

When I get the completed code in and I go back to the form and try the button I get this compile error:

"Method or Data Member not found"

and the .setfocus is highlighted in yellow?

What is going on???
Feb 20 '08 #3
missinglinq
3,532 Expert 2GB
I don't run 2007, but if I remember correctly, the command button wizard in this version creates embedded macros rather than the VBA code you're used to finding and modifying after creating a button in this manner. Take a look at this tutorial and see if it helps:

http://www.databasedev.co.uk/access2007macros.html

Welcome to TheScripts!

Linq ;0>
Feb 20 '08 #4
mshmyob
904 Expert 512MB
Linq is correct that if you use the Wizard to create an Addnew record in Access 2007 it uses a macro. But if you click on the drop down arrow on the ON CLICK event you will get 2 options. 1 for the macro and 1 for Event Procedure (which is the code). Select the Event Procedure and then you will be able to put in your code and the Macro will be void.

I have no problem getting to the VB Window. When I used the wizard to place a button in Access '03, there was code automatically placed in the VB Window for that control. When I look at the VB Window there is no code at all.

Here is the simple code that I am trying to put in for the cmdAdd button:


Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdAdd_Click()
  2. On Error GoTo Err_cmdAdd_Click
  3.  
  4.     DoCmd.GoToRecord , , acNewRec
  5.     LnameEng.SetFocus
  6.  
  7. exit_cmdAdd_click
  8.     Exit Sub
  9.  
  10. Err_cmdAdd_Click:
  11.     MsgBox Err.Description
  12.     Resume exit_cmdAdd_click
  13.  
  14. End Sub
  15.  
When I type in the doCmd line visual basic acts like I would expect and as soon as I type the two commas, the window pops up and gives me the choices to select such as asNewRec or acFirst or acLast. No problem there.

When I type in the line: LnameEng. I do not get the options I would expect like Setfocus, the only option I get is .value. This would lead me to believe that I had typed the name of the control in wrong, but I double checked the control name and LnameEng is correct and it is a text box and its tab stop value is set to Yes.

The biggest thing here is, I should not have to type in any code for the cmdAdd button because the Wizard should be doing that for me which it is not.

When I get the completed code in and I go back to the form and try the button I get this compile error:

"Method or Data Member not found"

and the .setfocus is highlighted in yellow?

What is going on???
Feb 20 '08 #5
Thank you for the replies to this question. Linq, you link to the information page gave me some good information and I also read some other pages that are getting me in the right direction.

Right now I can get to the VB Window just fine, but still there is limited functionality with VB.

When you use the wizard to create a button, it does write a macro and not VB. To convert it into VB you have to use a tool on the ribbon to manually create VB Code. I have no problem doing this.

When I go to the VB editor, i still cannot usede commands that were available in access '03, namely the Setfocus Method.

Is there something that is prohibiting VB. Is this prohibition something I can change to allow more code to be used.

According to the Microsoft webpage, they are trying to limit the use of code for security reasons and they have tried to make the Macros do the same thing, which they are no where near doing.

Has anyone else encountered this problem.

The biggest reason for me going to Access '07 is the ability to use access with sharepoint.

Thanks

Bob
Feb 20 '08 #6
mshmyob
904 Expert 512MB
I use Access 2007 and have created a number of apps with it and have not run into the problem yet. If you can send the file I could test it on my computer to see if I get the same problem..

Thank you for the replies to this question. Linq, you link to the information page gave me some good information and I also read some other pages that are getting me in the right direction.

Right now I can get to the VB Window just fine, but still there is limited functionality with VB.

When you use the wizard to create a button, it does write a macro and not VB. To convert it into VB you have to use a tool on the ribbon to manually create VB Code. I have no problem doing this.

When I go to the VB editor, i still cannot usede commands that were available in access '03, namely the Setfocus Method.

Is there something that is prohibiting VB. Is this prohibition something I can change to allow more code to be used.

According to the Microsoft webpage, they are trying to limit the use of code for security reasons and they have tried to make the Macros do the same thing, which they are no where near doing.

Has anyone else encountered this problem.

The biggest reason for me going to Access '07 is the ability to use access with sharepoint.

Thanks

Bob
Feb 21 '08 #7
mshmyob,
I really appreciate the offer although I do not know how to send it to you. My contact email is <<Removed due to site rules >> if you would like to contact me to give me instructions on how to get it to you.

Again Thanks

Bob
Feb 21 '08 #8
mshmyob
904 Expert 512MB
See at the bottom of your last post it says 'Edit/Delete'. Choose that and then scroll down and at the bottom of that page you will see an ATTACHMENT link. You can attach a ZIPPED file to your message there.

If you don't get that to work I will contact you via email. Let me know if you got it to work.

mshmyob,
I really appreciate the offer although I do not know how to send it to you. My contact email is <<Removed due to site rules >> if you would like to contact me to give me instructions on how to get it to you.

Again Thanks

Bob
Feb 21 '08 #9
NeoPa
32,556 Expert Mod 16PB
Bob,

It's not allowed to share e-mail addresses publicly in the forums (Check out Help for full explanations). It's probably best if you send your e-mail address to Mshmyob via PM.

Admin.
Feb 21 '08 #10
missinglinq
3,532 Expert 2GB
I know that in order for run VBA code under 2007 you have to declare the folder that the db resides in to be a trusted location. This is why apps from previous versions stop working when opened under 2007. I suppose it's possible Access won't let you write code unless the same thing is true. To do that:

Open A2007, click the "Office" button in the upper left, go to Access Options / Trust Center and add the source file of the db to the list of trusted locations.


Linq ;0)>
Feb 21 '08 #11
mshmyob
904 Expert 512MB
Hello Linq,

The trusted location annoyance - i mean setting that MS has added stops Macro's and Add-Ins from automatically running. If you open a database that isn't in the trusted location you get the MS standard message 'Do you want to enable macros ... etc. etc".

It doesn't stop you from adding code. Just FYI.

Cheers,

I know that in order for run VBA code under 2007 you have to declare the folder that the db resides in to be a trusted location. This is why apps from previous versions stop working when opened under 2007. I suppose it's possible Access won't let you write code unless the same thing is true. To do that:

Open A2007, click the "Office" button in the upper left, go to Access Options / Trust Center and add the source file of the db to the list of trusted locations.


Linq ;0)>
Feb 21 '08 #12
missinglinq
3,532 Expert 2GB
I don't run 2007, as I've stated, but according to multiple reports I've seen for months and months now, it stops code from running, without any warnings. Buttons with code behind them simply don't work until the db's folder is declared as a trusted location.

I'm not as clear on the warning you cited, about Macros, but I thought that started with ACC2003 and had to do with the level of security you set, not Trusted Locations.

Linq ;0)>
Feb 22 '08 #13
Linq,
I have made the location of my files a trusted location but I am still haivng problems with the code.

If I make a macro through the macro wizard and then convert that to VB Code, The code will appear in the VB window and will act like I expect. But if I try to add lines to the code (i.e. textbox.setfocus) I get an error on that line telling me that the Setfocus method cannot be found.

I am making progress albiet very slow progress. I am working this program for a friend of mine and would not use '07 except that is what he has on the system he is using.

Does anyone else believe that Microsoft has gone backward with Office '07?

Bob
Feb 22 '08 #14
missinglinq
3,532 Expert 2GB
Can you post the all of the code involved here (the entire sub) and the exact error message?

As to ACC2007, I look at it as more of a different app than a new version of an old app. I think it's going to go the route of VB6/VB.Net. Micro$oft thought that VB6
would be left by the wayside and everyone would jump on the VB.Net bandwagon, but that hasn't happened.

All these years later, VB6 is still chugging along, and I think what we're going to see is ACC2003 being used for years and years beyond when it would have been retired, if ACC2007 hadn't been such a departure..

I can see the reasoning behind the major changes in moving from VB6 to .Net, but I can't for the life of me see the reasoning behind interface/infrastructure changes they've made to Access in ACC2007!

Linq ;0)>
Feb 22 '08 #15
mshmyob
904 Expert 512MB
Airborne if you want you can PM me and I will give you my email to send the file to me so I can look at it.

Cheers,

Linq,
I have made the location of my files a trusted location but I am still haivng problems with the code.

If I make a macro through the macro wizard and then convert that to VB Code, The code will appear in the VB window and will act like I expect. But if I try to add lines to the code (i.e. textbox.setfocus) I get an error on that line telling me that the Setfocus method cannot be found.

I am making progress albiet very slow progress. I am working this program for a friend of mine and would not use '07 except that is what he has on the system he is using.

Does anyone else believe that Microsoft has gone backward with Office '07?

Bob
Feb 22 '08 #16
Are you using me.textbox.setfocus?
Feb 22 '08 #17

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

Similar topics

8
by: delete table with Visual Basic 6 | last post by:
Dear developer, I have an error message when I try to delete or drop Microsoft Access XP table with ADOX in Visual Basic 6. I use the ADOX.Catalog and ADOX.table to create and delete or drop table...
1
by: nicole bissell | last post by:
Hello, I am working in a new form and still making changes to the visual basic code of the form. Not always, but very often when I try to save my changes in the visual basic window and press the...
5
by: Microsoft | last post by:
Hi, I have Visual Basic .net 2003 (Standard Edition) & SQL Server 2000 Developer Edition. When trying to create a connection in the server explorer from the .net IDE I get a number of problems;...
10
by: Steve | last post by:
I am trying to create a DLL in Visual Studio 2005-Visual Basic that contains custom functions. I believe I need to use COM interop to allow VBA code in Excel 2002 to access it. I've studied...
1
by: praful pathak | last post by:
i i am praful pathak,porbandar i want to develop my own cross tab report in visual basic 6 i know what developed query from ms access but how to coded in visual basic in designing time and how to...
2
by: CAM | last post by:
Hello, I am wondering if someone can give me some pointers. Currently I am using Access 2002 I developed an inventory tracking database, which this database is used in California and in...
97
by: Master Programmer | last post by:
An friend insider told me that VB is to be killled off within 18 months. I guess this makes sence now that C# is here. I believe it and am actualy surprised they ever even included it in VS 2003 in...
1
by: FlyingBuckner | last post by:
All right be kind, this is my first question on a forum. I need help on selecting the right software to purchase. I have a database set up using Access, 6 users. It is split into Tables and...
1
by: Ronm | last post by:
Hey Guys, I have a problem which has been driving me crazy for the last days. I'm working on a small project involving: Visual Basic Acces Database ASP and adobe/macromedia Flash,
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
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...

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.