First Code Ever (1 Viewer)

jsanders

If I Only had a Brain
Local time
Today, 12:57
Joined
Jun 2, 2005
Messages
1,940
What was the first piece of VBA code you ever wrote?

I know mine.
 

FoFa

Registered User.
Local time
Today, 11:57
Joined
Jan 29, 2003
Messages
3,672
print "Hello World"
;)
 

Kraj

Registered User.
Local time
Today, 17:57
Joined
Aug 20, 2001
Messages
1,470
VBA...? Hmmm.... I think it was a DoCmd to open a form. I used it to make a custom button out of a label so I wasn't stuck with the ugly grey things for everything.
 

ShaneMan

Registered User.
Local time
Today, 09:57
Joined
May 9, 2005
Messages
1,224
txtName = [LastName] & ", " & [FirstName]

Was pretty proud of myself when I finally figured out to how to do it too!:)
 

jsanders

If I Only had a Brain
Local time
Today, 12:57
Joined
Jun 2, 2005
Messages
1,940
ShaneMan said:
txtName = [LastName] & ", " & [FirstName]

Was pretty proud of myself when I finally figured out to how to do it too!:)

Yup, that was one of mie also.

But numero uno was
Code:
DoCmd.maximize
on the on activate event.
 

jsanders

If I Only had a Brain
Local time
Today, 12:57
Joined
Jun 2, 2005
Messages
1,940
Rich said:
Why write any when you can just copy somebody elses? :cool:


Yup, Copying code lets me spend alot more time experimenting with Queries.
 

Ron_dK

Cool bop aficionado
Local time
Today, 18:57
Joined
Sep 5, 2002
Messages
2,141
First code ever was :

Option Compare Database
Option Explicit ;)


and the second was a macro I made which was converted to
a module :
Function McrImportCCC_copy()
On Error GoTo McrImportCCC_copy_Err

DoCmd.OpenTable "TbCCC", acNormal, acEdit
DoCmd.RunCommand acCmdSelectAllRecords
DoCmd.SetWarnings False
DoCmd.RunCommand acCmdDeleteRecord
DoCmd.SetWarnings False
DoCmd.Echo True, ""
DoCmd.TransferText acImportDelim, "Ccc Import Specification", "TbCCC", "C:\ccc.txt", False, ""
DoCmd.Close acTable, "TbCCC"


McrImportCCC_copy_Exit:
Exit Function

McrImportCCC_copy_Err:
MsgBox Err.description
Resume McrImportCCC_copy_Exit

End Function
:rolleyes:
 

ColinEssex

Old registered user
Local time
Today, 17:57
Joined
Feb 22, 2002
Messages
9,116
FoFa said:
print "Hello World"
;)
C: Print "Hello Colin"

On a Sinclair Spectrum in the 1980's that belonged to a friend.

Col
 

Ron_dK

Cool bop aficionado
Local time
Today, 18:57
Joined
Sep 5, 2002
Messages
2,141
I found this in one of my first Dbases :

Code:
Sub Combo254_AfterUpdate()
    ' Find the record that matches the control.
    Me.RecordsetClone.FindFirst "[Partij-ID] = " & Me![Combo254]
    Me.Bookmark = Me.RecordsetClone.Bookmark
End Sub

I didn't have a clue where it came from and what it did.:eek:
 

jsanders

If I Only had a Brain
Local time
Today, 12:57
Joined
Jun 2, 2005
Messages
1,940
BarryMK said:
DoCmd.AsktheForum ;)
That's good Barry.:cool:

Still one of my favorites.
 
Last edited:

Ron_dK

Cool bop aficionado
Local time
Today, 18:57
Joined
Sep 5, 2002
Messages
2,141
jsanders said:
That's good Barry.:cool:

Still one of my favorites.

Yes and in case of emergency :
DoCmd.QueryPatHartman ;)
 

reclusivemonkey

Registered User.
Local time
Today, 17:57
Joined
Oct 5, 2004
Messages
749
Code:
10 CLS
20 PRINT "Luke is Cool!!!"
30 GOTO 20

When I was a lad, infinite loops were positively encouraged ;-)
 

indesisiv

Access - What's that?
Local time
Today, 17:57
Joined
Jun 13, 2002
Messages
265
Code:
begin
  Writeln('Hello, World !');
end.

Here is the first code that I wrote. Back when i had to write stuff in pascal.

Steve
 

Ron_dK

Cool bop aficionado
Local time
Today, 18:57
Joined
Sep 5, 2002
Messages
2,141
jsanders said:
What was the first piece of VBA code you ever wrote?

I know mine.


Just out of curiosity JS, what was your last piece ? :cool:
 

indesisiv

Access - What's that?
Local time
Today, 17:57
Joined
Jun 13, 2002
Messages
265
rak said:
Just out of curiosity JS, what was your last piece ? :cool:

My last one was:

msgbox "Goodbye world!"

Steve:D :confused:
 

jsanders

If I Only had a Brain
Local time
Today, 12:57
Joined
Jun 2, 2005
Messages
1,940
rak said:
Just out of curiosity JS, what was your last piece ? :cool:

Now days i usually copy something from some other part of my stuff

You have to remember I use queries almost exclusively to control data.

But this is new.

Code:
Private Sub Status_AfterUpdate()
On Error GoTo Err_Status_AfterUpdate


    Dim stDocName As String
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.SetWarnings False

    stDocName = "QryServiceStatusAppend"
    DoCmd.OpenQuery stDocName, acNormal, acEdit
    
    Me.TblServiceStaus_subform.Requery
    
    DoCmd.SetWarnings True
    

Exit_Status_AfterUpdate:
    Exit SubErr_Status_AfterUpdate:
    MsgBox Err.Description
    Resume Exit_Status_AfterUpdate
    
End Sub



I use this to create a history of the changing status of a service order.

It runs an update query that gets its data from controls on the form and makes a new record. then it requeries the subform so you can see it.

Next I'm going to add a little code to disable the status controll after you click the complete (yes/no) control
 
Last edited:

Kraj

Registered User.
Local time
Today, 17:57
Joined
Aug 20, 2001
Messages
1,470
indesisiv said:
My last one was:

msgbox "Goodbye world!"

Steve:D :confused:
Don't you mean "Goodbye cruel world!"? ;)
 

indesisiv

Access - What's that?
Local time
Today, 17:57
Joined
Jun 13, 2002
Messages
265
Kraj said:
Don't you mean "Goodbye cruel world!"? ;)

I was going to put that but thought that it sounded just a little bit to final.

Steve
 

Users who are viewing this thread

Top Bottom