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

Problems with copying sample codes (MS Access)

Hi there,

I have a specific problem, but also wanted to guage everyone's thoughts on copying codes. For less knowledgeable people like myself, I sometimes find i difficult to write code from scratch, but now that I've been developing a database (with your help!) I'm starting to see how the code is working.

However, I recently copied some code to create an appointment in MS Outlook and adapted it to use existing data on my job form, as opposed to having the user enter everything from scratch.

AlthoughI adapted it, I keep getting a compile error for
Expand|Select|Wrap|Line Numbers
  1.  Dim objOutlook As Outlook.Application 
When I tested it in the database example I downloaded, my amendments worked. Now that I have copied the command click code into my database I'm getting compile errors. "User defined-type not defined"

So 2 questions:

1. Can anyone advise me on how to fix the compile error?

2. When copying code, do we just copy the code we see or are there other linked modules/macros etc that we should be copying as well?

Thanks,

Anthea
Jan 2 '07 #1
4 1513
pks00
280 Expert 100+
What u are using is the outlook activex control. What this means is if u use it this way then u have to add a reference. For any controls u use, u must add them as a reference. From vba window, u go to Tools/References and check the appropriate one (in this case Microsoft Outlook Object Library)

Do remember with Microsoft, there controls are in different directories depending on what version office u use therefore these become broken if used with a different version.

Using this approach is known as early binding.

Dim outApp as Outlook.Application

set outApp = New Outlook.Application


Now I prefer to code this way so as to make use of the intellisense menu,
However when I release change, I change it to use Late Binding

Late binding is basically you create objects then create them, What this saves is you having to add the reference in your code so u never suffer from broken references.
eg

Dim outApp as Object

set outApp = CreateObject("Outlook.Application")


There is a slight overhead with late binding, but not one that is noticable nowadays.
Jan 2 '07 #2
pks00
280 Expert 100+
Anthea

with regards to copying code, its all a learning process. You can copy a sample of code, and any additional stuff that u may need if specified.
If it doesnt work, see where the failings are and u may find u need to add something or change some declaration etc, it is not going to be the same thing.

In your case, its just knowing about adding references (early binding) and ive explained late binding as well, so hopefully now you understand.

The more u work with Access, the more comfortable and experienced you will become and you will soon learn what you need to do, just takes time Im afraid.

Good luck and Happy New Year :)
Jan 2 '07 #3
Hi there,

Thanks alot, that does make sense. One slight problem, I have NO idea where to put that first bit of code. I managed to find the references and select the Outlook option you mentioned.

But if I am to 'bind' globally (this is what I got from your post), I wasn't sure where to put the code:

Dim objOutlook As Outlook.Application

Set objOutlook = New Outlook.Application

Thanks

Anthea
Jan 2 '07 #4
Managed to get this working, so thanks for your help!
Jan 2 '07 #5

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

Similar topics

0
by: Mindy Smith | last post by:
Hello, when I installed Visual Basic .Net, for some reason it didn't install the sample codes. Does anyone know which CD the sample codes are on and how would I go about installing it on my hard...
5
by: Jim Andersen | last post by:
Hi, I made a DTS-package and it works when I execute it manually, but when it is run by the SQL Server Agent, it fails. I have use the guide to create a maintenance plan. That doesn't work so...
9
by: Christian Blackburn | last post by:
Hi Gang, I don't know what to make of all of this, but I'm having nothing, but trouble copying data to the clipboard which should be the easiest thing in the world. The only systems I can get...
1
by: Al Bahr | last post by:
Hi, Anyone aware of sample codes or article on creating Charts such as line, or Bar in VB.net? Thanks Al
5
by: DeanL | last post by:
Hi all, I'm having a few problems with a shared access 97 db. I have the database split with the tables on the server and everything else in "client" front ends with links to the tables, e.g....
9
by: Kelii | last post by:
I've been trying to get this piece to work for a few hours, but have given up. I hope someone out there can help, I think the issue is relatively straightforward, but being a novice, I'm stumped....
1
by: JoeZ | last post by:
Hi all, I am looking for some sample codes in C#, in which, it can read a schema xsd file and use it to validate an xml stream or file. Ideally the sample will use XmlValidatingReader. TIA, ...
0
by: smartx | last post by:
New sample codes, direct x game programming at: http://gptutors.com With best wishes, smartx.
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:
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
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
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.