D
David
Hello All,
I am a beginner when it comes to Access and wanted to know how to write
a code for my database. Arvin suggested a code like this
Sub cmdMyButton_Click (Cancel As Integer)
On Error GoTo Error_Handler
If Me.txtSKU < Val("66666 66666") Then
DoCmd.OpenReport "rptReport 1", , "SKU = '" & Me.txtSKU & "'
Else
DoCmd.OpenReport "rptReport 2", , "SKU = '" & Me.txtSKU & "'
End If
Exit_Here:
Exit Sub
Error_Handler:
MsgBox "You really screwed up this time", vbOKOnly, "Say FOOL!"
Resume Exit_Here
End Sub
I want a form so that the user can type in the product sku and if it is
within a certain range then a certain report will open. i.e. product
skus between 75000 00000 through 75000 00800 then report 1 will open
product skus 68000 00000 through 68000 00400 then report 2 will open and
everything outside these ranges report 3 will open.
And the second part of my question is to set this up I made a form with
a text box so the user could type in the sku along with a button. Is
this code supposed to be a procedure for the button. If so what in this
code looks at what has been typed in the text box. I am sorry if these
are stupid questions I really am not familiar with Access or VBA for
that matter.
All help is very much appreciated
Thank you,
David
I am a beginner when it comes to Access and wanted to know how to write
a code for my database. Arvin suggested a code like this
Sub cmdMyButton_Click (Cancel As Integer)
On Error GoTo Error_Handler
If Me.txtSKU < Val("66666 66666") Then
DoCmd.OpenReport "rptReport 1", , "SKU = '" & Me.txtSKU & "'
Else
DoCmd.OpenReport "rptReport 2", , "SKU = '" & Me.txtSKU & "'
End If
Exit_Here:
Exit Sub
Error_Handler:
MsgBox "You really screwed up this time", vbOKOnly, "Say FOOL!"
Resume Exit_Here
End Sub
I want a form so that the user can type in the product sku and if it is
within a certain range then a certain report will open. i.e. product
skus between 75000 00000 through 75000 00800 then report 1 will open
product skus 68000 00000 through 68000 00400 then report 2 will open and
everything outside these ranges report 3 will open.
And the second part of my question is to set this up I made a form with
a text box so the user could type in the sku along with a button. Is
this code supposed to be a procedure for the button. If so what in this
code looks at what has been typed in the text box. I am sorry if these
are stupid questions I really am not familiar with Access or VBA for
that matter.
All help is very much appreciated
Thank you,
David