calling a public function from a module

and not use the convert macro to code ability. It will give you a lot of junk code.

Bob Larson said the same when I posted up the result of a conversion.

The task of typing is a bit daunting but I thought I might just do representative bits of the data base.

Actually, I am most interested in being able to do the code that allows for tricky and nifty things to be done.
 
I would suggest that you read a few books and get some basic coding skills under your belt
Zaeed! You can't even navigate through a recordset! Are you sure you should be giving advice on this!? :D

(I am referencing the first of yours post I responded (long time ago)). :)
 
I doubt there is anything wrong with the code that you originally posted Matt
(see post #14)
Have you gotten that used to me asking questions that you think eveyone is me? :rolleyes:

LOL... Coding is something I can do, its the db stuff that im not used to... Im still not not 100% sure if what i'm doing is the correct method most of the time. Its all the refrencing and relationships, as well as how the data is handled.

I've programmed in Java and C in the past, and my comment was regarding peoples lack of understanding of calling functions with parameters.
 
Last edited:
Regardless of the language, programming basics remain the same.

a = a + 1 in Vb is a++ in C# and C++ (and now the "++" dork joke should make sense) and so on. It's branching and conditonals and looping and variable scope and the absolute basics that are true to every language. What changes is capability and syntax, although the difference in capability has become far smaller than it used to be.

If you're 100% new to coding, then coverting a macro to VBA in Access is not the worst thing in the world as it will show you how to do what you're used to. It just has a ton of extraneous crap included that 9 times out of 10, you don't need. It's like writing your webpage in Word, and then posting that to a website. Yes, it'll work, but good lord there's a ton of useless crap included.

The way to do it is to learn programming from a book, a class, etc., and then when you get stuck, you look at what the program will write for you. You should be able to pick out the BS from what is really needed, so long as you're understanding what's being automatically written. The program will never write anything beyond the basics, and even that is cluttered at best. It's supposed to stir the brain stew to get you to think of other ideas on how to get to a solution.

Yes, I'll often use somewhat advanced stuff in my examples, and no, I'm not some master, but once it starts to click, you too will grow to disregard macros for everything but a very few specific tasks (running a boatload of queries, for example). Even then, if that macro fails, you're SOL on debugging.

The point of this diatribe is that knowing what the coding should look like (even if you're not sure how to write it) is a step above expecting someone/something else to do it for you. Everyone learns in a different manner and some take to certain techniques better than others. In the end, practice makes perfect.
 
Moniker

I am OK on code for where I need it, and that is opening Word docs, bookmarks, copying the word.doc etc

I also have a couple of bits (courtesy of this site and dBForums) that are very good. No room for macros:D The bit I love the most is the one that removes duplicates on memo fields. This site said it can't be done. A bloke from Switzerland on dBForums said otherwise...and it works.

But when you get to "the mundane" the macros can have a lot going for them. In my case the data base has to work and people using it are insurance salesman (like me) and telemarketers. Macros are just easier to change. At 8pm when cold calling is happening and the telemarketer wants a change etc....Let me assure you the macro is easier. Do you have any idea how far removed Access Purity is when cold calling is being done.

People like to talk about how code is more efficient. Not when it is simple stuff opening a form and a couple of changes need to be made on the run. What I know is this.....perhaps code will open the form etc .00000000001 seconds quicker........but to change it, on the phone etc. code becomes real inefficient real quick.

Moniker, I think more people would listen if the people such as yourself were not so dogmatic. There is a reason why the hugely vast majority of the membership of this site never gets past 10 postings.

Mike
 
LOL... Coding is something I can do, its the db stuff that im not used to... Im still not not 100% sure if what i'm doing is the correct method most of the time.
Well, then maybe you should study a little more. :D :D :D

Have you any idea how many times I have had to discover code syntax and block ordering by trial and error!? Too many! But, I must say that when those little discoveries are made, they (most of the time) work wonders for my being able to create efficiencies for my line of work! :)
There is a reason why the hugely vast majority of the membership of this site never gets past 10 postings.
There sure is MIKE! Ya know why? 'Cuz if it did, the site would crash from memory overload. :eek:
 
lol....

Mike, Moniker was not refering to just access, he was refering to coding in general. By having coding skills, you gain an understanding of whats happening in your program, and it allows you to make it do whatever you want, and that is far more than what macros can offer. Having perfect knowledge of a programming language is not the point, the point is understanding the concepts of coding that are universal, such as loops, data structures, calling other methods etc. Having these skills makes life so much easier. A perfect example of that statement it me. I am at uni studying computer systems engineering, within that course if have done a fair few programming courses in java, C, SQL etc, giving me a solid understanding of coding. We have to do 'work experience' in the industry. I am now at a company building a change tracking system. When I got here I was told that I had to do it in access, for reasons i'm not going into here :mad:
Before this, I have only looked at access once, and for about 20mins when I first installed Office. Thats it. By using my knowledge of programming, and this site, I have been able to build (still going) a fairly complex (in my eyes at least) program, which i dont think would even be possible without the underlying programming that is running it.

If your new and still learning, yes macros are good, but as soon as you start to develop more sophisticated db's you really need to get down and dirty with the code.

The originaly topic regarding the calling of the function the perfect example where people didn't understand the programming fundamentals required to achieve the task at hand.

And regarding the 10 post thing, the reason is most people have a problem, thy create and account, get the problem solved, and then go away. They have no need to return. simple

Well, then maybe you should study a little more.
ha, im studying by doing.. I certainly follow the trial and error approach as well, although there is often more error than trial.
 
ok guys i really am a complete newbie at vba and programming in general i have found a public function on a website to reset any list or combo boxes on my form and i just need to figure out how to call this from a command button on any forms i want

the code is as follows

Public Function myReset(frm As Form)
Dim ctrl As Control
'For Each ctrl In Forms(frm)
For Each ctrl In frm
If ctrl.ControlType = acListBox Or ctrl.ControlType = acComboBox Then
ctrl.Value = Null
Else
End If
Next ctrl
End Function



any help would be great

To refresh the combo with new values

Code:
Public Function fReq()
    
    CodeContextObject.ActiveControl.Requery

End Function

and on the "on focus" of the combo

Code:
=fReq()
 
Last edited:
It would look something like this:-
Code:
Private Sub cmdResetLists_Click()

    myReset Me

End Sub
And you do not need the Else in the Function, and while you are at it you can remove the commented line.

The requery is a bit different. If you are going to have a GotFocus event for a Combo Box then I can’t really see the advantage in having another public procedure just in order to requery it. So just write the requery line in the GotFocus event.

CodeContextObject, don’t see that very often. Only one person on this site I know of who uses it.

Chris.
 

Users who are viewing this thread

Back
Top Bottom