Results 1 to 2 of 2
  1. #1
    alex_raju is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jun 2011
    Posts
    56

    Question code for blank text ???


    hi,

    when i enter invalid no below code is working fine
    If Me.ProductID.Value <> DLookup("ProductId", "Products") Then
    MsgBox "wrong no"
    SendKeys "{home}"
    Undo

    but if ProductID is blank below code is not working
    If isnull(me.ProductId) or Me.ProductID = "" Then
    Me.ProductID.SetFocus
    SendKeys "{home}"


    please give me a solution to work both option







    --------------------------------------------------------------------------


    Private Sub ProductID_AfterUpdate()
    On Error GoTo Err_ProductID_AfterUpdate

    Dim strfilter As String

    strfilter = "productID=" & Me!ProductID

    Me!UnitPrice = DLookup("UnitPrice", "Products", strfilter)

    Me.ProductID.SetFocus

    Exit_ProductID_Afterupdate:
    Exit Sub

    Err_ProductID_AfterUpdate:
    If Me.ProductID.Value <> DLookup("ProductId", "Products") Then
    MsgBox "wrong no"
    SendKeys "{home}"
    Undo
    Else
    If isnull(me.ProductId) or Me.ProductID = "" Then
    Me.ProductID.SetFocus
    SendKeys "{home}"
    End If
    End If
    End Sub

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,972
    Private Sub ProductID_AfterUpdate()
    On Error GoTo Err_ProductID_AfterUpdate

    If Me.ProductId & "" = "" Then
    Me.ProductID.SetFocus
    SendKeys "{home}"

    ElseIf Me.ProductID <> DLookup("ProductId", "Products") Then
    MsgBox "wrong no"
    SendKeys "{home}"
    Undo

    Else

    Me!UnitPrice = DLookup("UnitPrice", "Products", "productID=" & Me!ProductID)

    Me.ProductID.SetFocus

    End If

    Exit_ProductID_Afterupdate:
    Exit Sub

    Err_ProductID_AfterUpdate:

    End Sub
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Saving Module Code to Text Files
    By ioMatt in forum Modules
    Replies: 2
    Last Post: 07-02-2011, 08:18 AM
  2. Replies: 4
    Last Post: 05-11-2011, 03:06 AM
  3. Code in combobox, code in text box
    By float in forum Forms
    Replies: 3
    Last Post: 09-29-2010, 07:12 AM
  4. Replies: 20
    Last Post: 09-18-2010, 02:31 PM
  5. Replies: 1
    Last Post: 09-05-2008, 12:07 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