Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Macros / June 2005

Tip: Looking for answers? Try searching our database.

Macros vs. Code

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sharon - 29 Jun 2005 14:23 GMT
When I am in a field property and go to build an event, it asks me if I want
"Expression Builder", "Code Builder", or "Macro Builder".  I thought I would
do code builder and this is the code that I built:

Private Sub MethodofPaymentID_AfterUpdate()
   If frmPurchaseOrder.MethodofPaymentID = MasterCard Is True Then
       DoCmd.OpenForm frmExpenseReport
   Else: frmPurchaseOrder.MethodofPaymentID = MasterCard Is False
       DoCmd.GoToControl SupplierID
   End If  
End Sub

I don't know if this code is correct or anything, but when I try and test it
its bring up the macro name screen.  Do I have to name it with a macro name
and put the macro name into the after update property?  Obviously, I am new
to writing code, etc. but I was pretty proud that I managed to get through
this far without "Mr. Red" showing up.  Any help is appreciated.  Thanks.

Signature

S

Ken Snell [MVP] - 29 Jun 2005 14:45 GMT
When you view the Event tab of the Properties window for the
MethodofPaymentID control, does [Event Procedure] show in the box next to
After Update? If not, then the form does not know that you want to run VBA
code. The code that you wrote should be in the code module that is "behind"
the form, and the [Event Procedure] text should be in that property box.

Signature

       Ken Snell
<MS ACCESS MVP>

> When I am in a field property and go to build an event, it asks me if I
> want
[quoted text clipped - 18 lines]
> to writing code, etc. but I was pretty proud that I managed to get through
> this far without "Mr. Red" showing up.  Any help is appreciated.  Thanks.
Sharon - 29 Jun 2005 15:01 GMT
Yes, [Event Procedure] shows on the line "After Update" but nothing happens
when I update the field.  Hold on . . . I thought I would double check and
for some reason it is recognizing the code.  Sorry, but I think when I copied
the [Event Procedure] and moved it to After Update rather than on Exit, I did
not know that I needed to go into the code and change it there.  So, now, it
runs but I get the error message "Compile Error: Type mismatch" on the "is
True" statement.  I am not sure how to tell it that if I choose "Mastercard"
in the drop down to open another form but if it is NOT "Mastercard," then
just go to the next field.
Signature

S

> When you view the Event tab of the Properties window for the
> MethodofPaymentID control, does [Event Procedure] show in the box next to
[quoted text clipped - 24 lines]
> > to writing code, etc. but I was pretty proud that I managed to get through
> > this far without "Mr. Red" showing up.  Any help is appreciated.  Thanks.
Van T. Dinh - 29 Jun 2005 16:23 GMT
"Is" in this syntax operates on Objects, not Values.

Also, the syntax of the Boolean expression looks incorrect.

What is the Data-Type for MethodofPaymentID?

If it is Text, I think you need:

If (Forms!frmPurchaseOrder.MethodofPaymentID = "MasterCard") Then
   ...

I am not sure what you tried to do with the statement:

frmPurchaseOrder.MethodofPaymentID = MasterCard Is False

Signature

HTH
Van T. Dinh
MVP (Access)

> Yes, [Event Procedure] shows on the line "After Update" but nothing happens
> when I update the field.  Hold on . . . I thought I would double check and
[quoted text clipped - 5 lines]
> in the drop down to open another form but if it is NOT "Mastercard," then
> just go to the next field.
Steve Schapel - 29 Jun 2005 20:08 GMT
> I am not sure what you tried to do with the statement:
>
> frmPurchaseOrder.MethodofPaymentID = MasterCard Is False

I think it means this:
 Me.MethodofPaymentID <> "MasterCard"

But in the end, I think the code required is:
    If Me.MethodofPaymentID = "MasterCard" Then
        DoCmd.OpenForm frmExpenseReport
    Else
        DoCmd.GoToControl SupplierID
    End If

Signature

Steve Schapel, Microsoft Access MVP

Van T. Dinh - 29 Jun 2005 23:45 GMT
That's what I guessed but the O.P. used "Else" with the colon after so the
statement looks like an assignment statement, not a Boolean expression being
used as criteria (for ElseIf?)

Signature

Cheers
Van

> > I am not sure what you tried to do with the statement:
> >
[quoted text clipped - 9 lines]
>          DoCmd.GoToControl SupplierID
>      End If
Steve Schapel - 30 Jun 2005 01:02 GMT
Van,

I cheated ;-)  I also read right through to the last sentence of her
last post <g>

Signature

Steve Schapel, Microsoft Access MVP

> That's what I guessed but the O.P. used "Else" with the colon after so the
> statement looks like an assignment statement, not a Boolean expression being
> used as criteria (for ElseIf?)
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.