Advertisement

05.19.2008 at 03:10AM PDT, ID: 23413129
[x]
Attachment Details

Macro for Form HELP!!

Asked by onaled777 in Access Coding/Macros, Access Forms

Tags: Microsoft, Access, 2003

This is my first try @ an access macro & I seem to me getting nowhere fast. I have a macro that is supposed to check to see if the user is trying to enter a duplicate PO number and if so erase that record and take the user to the original record. I enter this macro on the form & then when trying to test it get a data type mismatch in criteria expression error.  If anyone can take a look to let me know what I am doing wrong would be much appreciated. Thanks in advance Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
Private Sub PurchaseOrderNumber_BeforeUpdate(Cancel As Integer)
Dim SID As String
    Dim stLinkCriteria As String
    Dim rsc As DAO.Recordset
 
    Set rsc = Me.RecordsetClone
 
    SID = Me.PurchaseOrderNumber.Value
    stLinkCriteria = "[PurchaseOrderNumber]=" & "'" & SID & "'"
 
    'Check PurchaseOrder table for duplicate PurchaseOrderNumber
    If DCount("PurchaseOrderNumber", "tblPurchase Orders",
              stLinkCriteria) > 0 Then
        'Undo duplicate entry
        Me.Undo
        'Message box warning of duplication
        MsgBox "Warning Student Number " _
             & SID & " has already been entered." _
             & vbCr & vbCr & "You will now been taken to the record.", _
               vbInformation, "Duplicate Information"
        'Go to record of original Student Number
        rsc.FindFirst stLinkCriteria
        Me.Bookmark = rsc.Bookmark
    End If
 
    Set rsc = Nothing
End Sub
[+][-]05.19.2008 at 03:15AM PDT, ID: 21596362

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.19.2008 at 07:20AM PDT, ID: 21597994

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.20.2008 at 08:31AM PDT, ID: 21607141

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.04.2008 at 07:17AM PDT, ID: 21710327

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Access Coding/Macros, Access Forms
Tags: Microsoft, Access, 2003
Sign Up Now!
Solution Provided By: Mr_Ben
Participating Experts: 3
Solution Grade: A
 
 
[+][-]06.04.2008 at 08:45AM PDT, ID: 21711249

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628