Results 1 to 5 of 5
  1. #1
    rev_ollie is offline Novice
    Windows 7 Access 2007
    Join Date
    Sep 2008
    Posts
    12

    Locking form with Visual Basic

    Hey,



    I've been learning alot but have one final question regarding my access database.
    I have a button that locks certain field on my form Orders and then generates the Invoice form.
    However when I click the button it all goes through except I get this error:

    Object doesn't support this property or method

    Also when I click the button it locks all of the records.
    Is there a way to only lock a certain record on which I click the button.
    For example If I click the button on Order ID 1 is will only lock that record and no others.

    This is the code on the button:
    Code:
    Private Sub Generate_Invoice_Click()
    On Error GoTo Err_Generate_Invoice_Click
    Dim stDocName As String
        Dim stLinkCriteria As String
    
        stDocName = "Invoice"
        
        stLinkCriteria = "[Order ID]=" & Me![Order ID]
        DoCmd.OpenForm stDocName, , , stLinkCriteria
        Text_field.Value = "Invoice Printed"
        Me![Order ID].Locked = True
        Me![Customer ID].Locked = True
        Me![Order Date].Locked = True
        Me![Payment Type].Locked = True
        Me![Job Description].Locked = True
        
    Exit_Generate_Invoice_Click:
        Exit Sub
    
    Err_Generate_Invoice_Click:
        MsgBox Err.Description
        Resume Exit_Generate_Invoice_Click
    End Sub

  2. #2
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    Text_field.Value = "Invoice Printed"

    What is the purpose of this. is There a text box on the form named Text_Field.

  3. #3
    rev_ollie is offline Novice
    Windows 7 Access 2007
    Join Date
    Sep 2008
    Posts
    12
    Yeah I added that in.
    When the button is pressed it prints Invoice Printed in the text field to show the invoice as printed.

  4. #4
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    yes if you put the following code on the on click even of OrderID
    Me![Order ID].Locked
    OrderID will be locked.

  5. #5
    rev_ollie is offline Novice
    Windows 7 Access 2007
    Join Date
    Sep 2008
    Posts
    12
    So is there a way you know of where I casn just lock 1 record.

    Its just locking every record in the orders form but if the invoice hasn't been sent I need to be able to make changes still.

    Is that possible or can you not lock specific records?

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Using Access Instead of Visual Basic
    By dinz in forum Programming
    Replies: 2
    Last Post: 12-19-2019, 10:33 AM
  2. Record Value in Visual Basic
    By chrismec in forum Programming
    Replies: 3
    Last Post: 12-09-2009, 04:14 PM
  3. microsoft visual basic REFERENCE
    By marianne in forum Access
    Replies: 0
    Last Post: 04-01-2009, 08:06 PM
  4. Problem when activate the Visual Basic Editor
    By milo in forum Programming
    Replies: 0
    Last Post: 05-21-2007, 09:05 AM
  5. Visual Basic ToolBar and ImageList
    By Athanasopolous in forum Programming
    Replies: 0
    Last Post: 01-17-2006, 03:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums