First Code Ever

Here is the code for the last DB
 

Attachments

I don't remember my first code, but this is my first exe file I wrote with VB 6.0. I was so proud. They still use this li'l calculator to this day!!

This is what got me hooked on coding and Access!!!!

Code:
Private Sub cmdCalculate_Click()
'Calculate Samples Size

Dim X As Variant
Dim Prec As Variant
Dim P As Variant
Dim N As Variant
Dim Samplesize As Integer

'If has null value pop up msg
If txtAccuracy = "" Or txtPrec = "" Or txtVolume = "" Then
MsgBox " Unable to calculate due to blank fields. Please enter a valid number."

Else
    ' Or if has all zeros pop up message box
    If txtAccuracy = "0" And txtPrec = "0" Or txtVolume = "0" Then

    MsgBox "Unable to calculate with all zeros (0)"
    

Else

'Then continue calculation
'For Proportion

P = Me![txtAccuracy] / 100
Prec = Me![txtPrec] / 100
N = Me![txtVolume]

X = ((1.96 / Prec) ^ 2) * (P * (1 - P))

Samplesize = X / (1 + ((X - 1) / N))

Me![txtSampleRequired] = Samplesize
        End If
        
    End If
    

End Sub

Private Sub cmdClear_Click()

txtAccuracy = ""
txtPrec = ""
txtSampleRequired = ""
txtVolume = ""

End Sub

Private Sub cmdPrint_Click()

Dim Msg ' Declare variable.
On Error GoTo ErrorHandler ' Set up error handler.
PrintForm ' Print form.
Exit Sub
ErrorHandler:
Msg = "The form can't be printed."
MsgBox Msg ' Display message.
Resume Next
End Sub
 
Last edited:
I remember now when I was alot younger.

I wanted to install Kings Quest, or was it a typing program, on our brand new pc. I can't remember. It was ran with DOS.

My cousins told me I had to

c:/format ~~~ Before I could load it to the PC. I think it was something to that affect.

Well, needless to say, I wasn't allowed to play on the compture for along time.
 
selenau837 said:
My cousins told me I had to

c:/format ~~~ Before I could load it to the PC. I think it was something to that affect.

That wasn't very nice. :p

I can't remember my first VBA code ever, although I was doing a lot of playing in a test db I created for myself to mess up and I was copying existing stuff from someone else's db and changing bits here and there so I could learn what everything did.

My first piece of actual VB code was probably along the lines of Fofa's "Hello World" as I was reading a book to teach myself and that is where they always start. :D
 
MrsGorilla said:
That wasn't very nice. :p
Yeah, tell me about it. My dad was soooooo mad. He still won't let me forget it either. He told me since I am in school for computer programming, he MAY let me on his PC. :eek:


My first piece of actual VB code was probably along the lines of Fofa's "Hello World" as I was reading a book to teach myself and that is where they always start. :D

Yea, I saw that too when I was reading and teaching myself, but I found that way to boring and skipped that. Yes, I am an impatient learner.

However I was tossed into VB. The database I know admin was written strickly with VB so I was tossed in head first and said sink or swim. I sunk for a while, but I am slowly coming up for air.
 
jsanders said:
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
[/QUOTE]


Mmmmm, you should be aware that the DoMenu Item has been obsolete for years and should no longer be used, replace it with the RunCommand constants instead. In this instance it should be 
RunCommand acCmdSaveRecord
 
Rich said:
Mmmmm, you should be aware that the DoMenu Item has been obsolete for years and should no longer be used, replace it with the RunCommand constants instead. In this instance it should be
RunCommand acCmdSaveRecord

What's the advantage?
 
jsanders said:
That's good Barry.:cool:

Still one of my favorites.

Being a bear of very little brain I still use it all the time although nowadays I am able to put some code in place first then call the Forum when it doesn't work - so I guess that could be called progress.
 
Public Sub Loo()
Dim intYes As Integer
Dim varStr As String
Do Until varStr = "strLocalStoreStopsSellingToiletPaper"

DoCmd.OpenForm "ThereOnceWasAPersonFromEaling", acPreview, _
"qryWhoTriedTo______"
WhereCondition: "[QuiltedBeatsAllAndFeelsComfyToo]=" & intYes

varStr="WeRanOutHonest" '******Thought u might like that!

Loop
End Sub

*scratches head* (Di ya really wanna acPreview? LOL)

:P

**No offence to anyone and hope I don't get booted from this wonderful forum**
 
I'm very fond of mine

Private Sub Numpty_Click()

MsgBox "If you click this you are a numpty", vbOKOnly, "Numpty"

End Sub
 

Users who are viewing this thread

Back
Top Bottom