473,785 Members | 2,310 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help with some VB Code

Here is what I have so far, it loops while the PW is incorrect, or
until cancel is selected. I want it to lock the tables for adds,
deletes, and edits when cancel is selected, and if the PW is correct.

I want this to run when the DB is opened, I would also like the text
box to be starred (*) out when text is input.

Thanks for your help.

=============== ===============
Dim Show_Box As Boolean
Dim Response As String

' Set the Show_Dialog variable to True.
Show_Box = True
InputBox
' Begin While loop.
While Show_Box = True

' Show the input box.
Response = InputBox("Enter the Password to Unlock Read-Only
Mode.", _
"Read-Only Unlocking")
' See if Cancel was pressed.
If Response = "" Then

' If Cancel was pressed,
' break out of the loop.
Show_Box = False
Else
' Test Entry to find out if it is the correct password.
If "safety" = Response = True Then
'Application.Cl oseCurrentDatab ase
'Application.DB Engine.OpenData base "P:\ACTION REGISTER
\TESTERIncidet Action Register Database.mdb", , True
'Application.Op enCurrentDataba se "P:\ACTION REGISTER
\TESTERIncidet Action Register Database.mdb", False
'Access.AcOpenD ataMode.acReadO nly
Show_Box = False
Else
' If the entry was wrong, show an error message.
MsgBox "Wrong Password, Try again."
End If
End If
' End the While loop.
Wend
=============== =============== =============== =
Jun 27 '08 #1
15 2073
Hello,

The functionality you are trying to achieve with your code is not
supported in VBA because it requires a multithreaded environment which
would involve programming in an Object Oriented Programming platform
(OOP -- C#, VB.Net, Java...). VBA is not Object Oriented -- it is
Interpreted. The VBA compiler interprets the code as it runs thus not
requiring to compile the code into an exe which makes programming and
debugging as easy as can be. The limitation of Interpreted programming
code is that you can't perform OOP operations. It is either one or the
other. For the functionality you desire -- I would try VB.Net -- it is
the easiest OOP language to use.

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Jun 27 '08 #2
"Rich P" <rp*****@aol.co mwrote in message
news:12******** *****@news.news feeds.com...
Hello,

The functionality you are trying to achieve with your code is not
supported in VBA because it requires a multithreaded environment
No, the simple code posted does not need threading. The looping is ONLY
there for re-prompting the user, not the requiremnt to span a new thread.
which
would involve programming in an Object Oriented Programming platform
No, opp and threading are separate issues. The idea, concpet and
implementation of a threaded language does not require that it be an object
oriented platform at all. The idea of having threaded code does not require
you to have a opp lanaguge.
(OOP -- C#, VB.Net, Java...). VBA is not Object Oriented -- it is
Interpreted.
I hate to burst your bubble but c#, and the .net actually now use a runtime
p-code system, and is in fact compiled down into a intermediate language
that is interpreted by the CLR (common language runtime). So in this case
C#, vb.net, and VBA actually are now all compiled to an intermediate
language, or what is called a p-code system. What this means is none of
these languages actually now compile down to into true .exe files that the
intel Processor can consume. This means that your file extension of .exe, or
mdb, or whatever you choose is in fact a moot point at this point in time
now.

It is interesting that us VBA developers for years and years have been using
a p-code interpreted system, and now both c# and vb.net use a similar
architecture.
The VBA compiler interprets the code as it runs thus not
requiring to compile the code into an exe which makes programming and
debugging as easy as can be.
Once again this is complete wrong. In fact debugging systems tend to work
better when you have an intermediate p-code language. While the dot net
compilers appear to produce a .exe file, this is actually not a true
compiled file, and is NOT a native executable file. In fact the.net
debugging systems use the p-code intermediate language to their benefit, and
not their detriment as you're suggesting.

VBA does have a compiler, and it does compile it down to a p-code lanague
that is then interpreted by runtime system. So, for all of the syntax error
checking, compiling, and removal of comments from the source code, this
process is much the same in VBA as it is now in .net.

The resulting compiled file in vb.net, or in ms-access results in a p-code
(intermediate language) that then gets executed an runtime system

.. c#, and vb.net (or any other language you use that converts into the
common runtime language) STILL requires you have the.net library or runtime
system installed to interpret that code. It is not natively compiled, and
therefore this also explains why you can do x-copy development in vb.net (or
in ms-access) after you've installed the appropriate libraries that can
interpret the code that gets created by these systems.

I should point out that c++, or the even the last version of visual basic
6.0 did have a native compiler, and these two systems could in fact produce
true .exe files that could be interpreted by the Intel processor direclty
(this is TRUE native .exe's now). These resulting files of course did
require access to the windows api, but there was not an intermediate
interpreter (p-code) system like you have with .net.

The limitation of Interpreted programming
code is that you can't perform OOP operations.
Once again this is wrong, because .net is *like* an interpreted language.
Java is considered a oop language, and it does not produce native
executables in most implementations either Once you've compiled to the
p-code system, then the idea here is that supposedly your code is platform
more portable. As long as you write a p-code interpreter for that platform,
all of your code should work.

I should point out this is also why it for example you can use visual studio
to produce .net code for the mobile edition of windows (which by the way,
does not have an Intel compatible processor), or the XNA for the xbox.
It is either one or the
other.
No, it is not one choice or the other when you choose an interpreted versus
that of a compiled language. OOP operations are not exclusive to compiled
languages only.

As I pointed out the .net system is in fact interpreted language system. I
should point of course that the CLR has its own compiler that is independent
of what language you program in. The CLR interpreter does in fact have a JIT
(just in time compiler) that'll eventually take that p-code and compiles it
into the native language of your machine (in this case the Intel processor),
So I will admit that how the CLR functions is not a true p-code architecture
in the classic sense of Java, or VBA.

I'm open to being corrected on this architecture issue, but it is my
assumption that your .exe files created by the .net library in is fact a CLR
p-code .exe, and is not a native true compiled language until the JIT gets
its hands on this .exe file. You can however pre compiled.net applications
using the ngen utility.

The issue of having a full opp language, or having a language that supports
threading, has no relationship to the fact if the language is a native
compiled language, or a p-code interpreted language at all.

**Both** both of those types of languages can well implement opp features,
and also that of threading.

I should point out the MS access does allow you to create and build your own
class objects. However, the vba in access is not considered a full opp
language because it's missing features like inheritance, and a number of
other things what would give it a full oop badge.

You can read my article on building and using class objects in MS access
here:
http://www.members.shaw.ca/AlbertKal.../WhyClass.html

Keep in mind that MS access shares the same compiler as vb 6.0 but simply
does not allow us to produce a native.exe like vb 6.0 did (vb 6 allowed the
creation of both native .exe executables, or the choice of using p-code --
Once again an issue that's been dependent of oop, or threading).

--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl************* ****@msn.com
Jun 27 '08 #3
On May 5, 3:07*pm, colemanj4 <colema...@gmai l.comwrote:
Here is what I have so far, it loops while the PW is incorrect, or
until cancel is selected. I want it to lock the tables for adds,
deletes, and edits when cancel is selected, and if the PW is correct.

I want this to run when the DB is opened, I would also like the text
box to be starred (*) out when text is input.

Thanks for your help.

=============== ===============
*Dim Show_Box As Boolean
* * Dim Response As String

* * ' Set the Show_Dialog variable to True.
* * Show_Box = True
InputBox
* * ' Begin While loop.
* * While Show_Box = True

* * * * ' Show the input box.
* * * * Response = InputBox("Enter the Password to Unlock Read-Only
Mode.", _
* * * * * * "Read-Only Unlocking")
* * * * ' See if Cancel was pressed.
* * * * If Response = "" Then

* * * * * * ' If Cancel was pressed,
* * * * * * ' break out of the loop.
* * * * * * Show_Box = False

* * * * Else
* * * * * * ' Test Entry to find out if it is the correct password.
* * * * * * If "safety" = Response = True Then
* * * * * * * * 'Application.Cl oseCurrentDatab ase
* * * * * * * * 'Application.DB Engine.OpenData base "P:\ACTION REGISTER
\TESTERIncidet Action Register Database.mdb", , True
* * * * * * * * 'Application.Op enCurrentDataba se "P:\ACTION REGISTER
\TESTERIncidet Action Register Database.mdb", False
* * * * * * * * 'Access.AcOpenD ataMode.acReadO nly
* * * * * * * * Show_Box = False
* * * * * * Else
* * * * * * * * ' If the entry was wrong, show an error message.
* * * * * * * * MsgBox "Wrong Password, Try again."
* * * * * * End If
* * * * End If
* * * ' End the While loop.
* * * Wend
=============== =============== =============== =
OK, since what I want to do doesn't seem possible, is there a way I
could set the current user to user level access instead of admin? I
don't want ot get into doing all of the security wizard access has, as
I have tried it multiple times and it is not working. I believe that
is because of the way my corporate IT has the permissions set up for
the whole network, and they are a pain to get involved with.

So... say doej is the user, he opens up the DB, and is asked for a
password, he hits cancel and I then want to delegate him to the "User
group" which only has readonly access. Can I do this with my VBA
code?

Thanks
Jun 27 '08 #4

Excellent response, Albert. I can't think of anything to add except a
resounding expression of agreement.
On May 6, 2:00*am, "Albert D. Kallal" <PleaseNOOOsPAM mkal...@msn.com >
wrote:
"Rich P" <rpng...@aol.co mwrote in message
I hate to burst your bubble but c#...
Jun 27 '08 #5
On Tue, 06 May 2008 06:00:43 GMT, "Albert D. Kallal"
<Pl************ *******@msn.com wrote:
In fact, you *can* do multithreading with VBA, same as with VB6. For
example see here: http://www.freevbcode.com/ShowCode.Asp?ID=1287
and heed that warning not to do it unless you are an expert
programmer!

-Tom.

>"Rich P" <rp*****@aol.co mwrote in message
news:12******* ******@news.new sfeeds.com...
>Hello,

The functionality you are trying to achieve with your code is not
supported in VBA because it requires a multithreaded environment

No, the simple code posted does not need threading. The looping is ONLY
there for re-prompting the user, not the requiremnt to span a new thread.
>which
would involve programming in an Object Oriented Programming platform

No, opp and threading are separate issues. The idea, concpet and
implementati on of a threaded language does not require that it be an object
oriented platform at all. The idea of having threaded code does not require
you to have a opp lanaguge.
>(OOP -- C#, VB.Net, Java...). VBA is not Object Oriented -- it is
Interpreted.
<clip>
Jun 27 '08 #6
I have writtens lots of multi threaded programs. The only way you can
do it in VBA is like this:

"It can't be done!"

I have been posting in this newsgroup for several years. I have
probably not been on planet earth as long as a lot of you, but I have
taken the coding thing a little bit further. If what I say was not true
and correct, I would have disappeared a long time ago - from attrition -
as in no one would need my services. You can't do multi threading in
VBA - I have tried. The closest I came was to create to separate exe's
in VB6 where one exe monitored the operations of the other. But that is
not VBA, and that was in the previous century.

It is one thing to be an Access coder, and if that is the extent of your
horizons, fine. But for those people who need functionality that is
either not provided in this environment - or not provided easily - it is
time to step up to something a little more sophisticated. My goal is to
share how to achieve desired results with as little spaghetti code as
possible. If an operation requires tons of spaghettie code (API code,
etc) then it is time to start investigating other technologies.

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Jun 27 '08 #7
Silly me! I am tooting my horn about how VBA doesn't support
multithreading and that you can only do it in OOP. I forgot to mention
that multithreading requires the use of delegates - here is some sample
code of a program I wrote which does something similar to what this post
is about - being able to control the execution of an operation -
start/stop:
Public Delegate Sub StartSlideShowD elegate()
Private Delegate Sub ShowPicsDelegat e(ByVal PicCount As
Integer, ByVal str2 As String)
...

btnStopStart.Te xt = "Stop SlideShow"
btnSinglePicBac k.Enabled = False
btnSinglePicFwd .Enabled = False
bRunPics = True
Dim dlgt As StartSlideShowD elegate = New
StartSlideShowD elegate(Address Of StartLoadSlideS how)
Dim state As Integer = 0
Dim ar As IAsyncResult = dlgt.BeginInvok e(New AsyncCallback
(AddressOf DoneCallback), state)
...

Try
If Me.InvokeRequir ed Then
' if operating on a thread, invoke a delegate
' on the UI thread.
Dim omd As ShowPicsDelegat e = New ShowPicsDelegat e
(AddressOf ShowPics)
Dim arx As IAsyncResult = Me.BeginInvoke( omd, New
Object() {PicCount, str2})
Me.EndInvoke(ar x)
Return
End If
...

--you can't do this in VBA. You can only do this in OOP.

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Jun 27 '08 #8
"Rich P" <rp*****@aol.co mwrote in message
news:12******** ******@news.new sfeeds.com...
>I have writtens lots of multi threaded programs. The only way you can
do it in VBA is like this:

"It can't be done!"

I for the most part 100% agree with the above.
If what I say was not true
and correct, I would have disappeared a long time ago - from attrition -
Your claim about VBA and threading is 100% correct. however, you claim of to
quote:
>The functionality you are trying to achieve with your code is not
supported in VBA because it requires a multithreaded environment which
would involve programming in an Object Oriented Programming platform

You DO NOT need to adopt a OOP platform to get threading. Without question
*most* modern development systems that supprot oop *useally* also support
threading, but, your above claim says that you **have** to use a OOP system
to get multithread enviroment is wrong. I was simply pointing out that these
are two mutually exclusive issues, and are not related to each other. Once
again, you do not necessarily have to adopt a oop language to get
multithreading capability.
>The limitation of Interpreted programming
code is that you can't perform OOP operations.

Once again I said the above is incorrect, and there are many interpreted
languages is today that are full oop. And, I pointed out that in fact the
..net environment relies on a p-code runtime system, very similar to that of
the vba. (and I believe on windows mobile, and also the XNA system for xbox,
there is no JIT either).

I was never questioning you're correct suggestion that threading in VBA is
silly, and the wrong tool and one is barking up the wrong tree to attempt
threading in VBA. Once again, I wholeheartedly agree with you on this issue.
It is silly and simply not the realm of VBA to write and build threaded
applications.

I should further point out that if I'm reading the original poster's
question correctly, he does not need threading as a solution anyway...
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl************* ****@msn.com
Jun 27 '08 #9
Actually, I have to run right now...but, let me take a look at this later
tonight....

I do think something can be cooked up here.....
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl************* ****@msn.com
Jun 27 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2757
by: PHPkemon | last post by:
Hi there, A few weeks ago I made a post and got an answer which seemed very logical. Here's part of the post: PHPkemon wrote: > I think I've figured out how to do the main things like storing products in
3
1593
by: Mike | last post by:
Hey guys I am pulling my hair out on this problem!!!!! Any help or ideas or comments on how to make this work I would be grateful! I have been working on this for the past 4 days and nothing I do seems to get me any closer to the solution. Below is a program that I am working on for a class project. The original code was provided for us which is what I have below. What we have to do is make the app run so that it allows the user to add...
8
3023
by: MattP | last post by:
Ok, with the help of some examples found on the web and some minor modifications on our own, we have a simple and working encrypt and decrypt solution. It runs as a service, watches for files with a specific extension in a specific directory. The files are uploaded by FTP to this directory. The service then does the following steps: 1) Verify it can open the file (so we know it's fully uploaded). 2) Try to decrypt the file with known...
28
3307
by: stu_gots | last post by:
I have been losing sleep over this puzzle, and I'm convinced my train of thought is heading in the wrong direction. It is difficult to explain my circumstances, so I will present an identical make-believe challenge in order to avoid confusing the issue further. Suppose I was hosting a dinner and I wanted to invite exactly 12 guests from my neighborhood. I'm really picky about that... I have 12 chairs besides my own, and I want them all...
16
2592
by: expertware | last post by:
Dear friends, My name is Pamela, I do not know anything about javascript, but I would like to ask if it offers a solution to this problem of mine. I have an image on a web page within a css layer: <DIV ID=MyLayer STYLE = "position: absolute;top:68px; left:563px;
23
3287
by: Jason | last post by:
Hi, I was wondering if any could point me to an example or give me ideas on how to dynamically create a form based on a database table? So, I would have a table designed to tell my application to create certain textboxes, labels, and combo boxes? Any ideas would be appreciated. Thanks
3
3740
by: inkexit | last post by:
I need help figuring out what is wrong with my code. I posted here a few weeks ago with some code about creating self similar melodies in music. The coding style I'm being taught is apparently a lot different from what the pros around here use. I really need help with debugging some program errors more than anything, even though my coding style might not be perfect. Anyway here is my code. About the only things that work right are...
16
2820
by: Rex | last post by:
Hi All - I have a question that I think MIGHT be of interest to a number of us developers. I am somewhat new to VIsual Studio 2005 but not new to VB. I am looking for ideas about quick and efficient navigating within Visual Studio 2005. Let's say your project (or solution) has dozens of forms and hundreds or even thousands of routines. Two Questions: 1) BUILT-IN to Visual Studio 2005. What ideas do you have to quickly
15
2581
by: Jay | last post by:
I have a multi threaded VB.NET application (4 threads) that I use to send text messages to many, many employees via system.timer at a 5 second interval. Basically, I look in a SQL table (queue) to determine who needs to receive the text message then send the message to the address. Only problem is, the employee may receive up to 4 of the same messages because each thread gets the recors then sends the message. I need somehow to prevent...
0
5576
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted ******************************************************** For this teeny job, please refer to: http://feeds.reddit.com/feed/8fu/?o=25
0
9647
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10356
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10161
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7506
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5390
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4058
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3662
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2890
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.