p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Beginning VB.NET Databases (http://p2p.wrox.com/forumdisplay.php?f=147)
-   -   object variable or with block variable not set (http://p2p.wrox.com/showthread.php?t=39003)

Aoude February 24th, 2006 05:01 PM

object variable or with block variable not set
 
I don't know why I keep getting this msg?!? Code below...help!!

Option Compare Database
Option Explicit

Private Sub Save_IP_Type_Button_Click()
On Error GoTo Error_Sub

    Dim inputTypeID As Variant
    Dim inputType As Variant
    inputTypeID = Me!IPTypeID
    inputType = Me!IPType

    If IsNull(inputTypeID) Then
        MsgBox "You must enter an IP acronym!", vbExclamation, "No Acronym Entered"
    ElseIf IsNull(inputType) Then
        MsgBox "You must enter an IP type!", vbExclamation, "No Type Entered"
    Else
        Dim table As Recordset
        Set table = globalDatabase.OpenRecordset("SELECT * FROM IPTypeLookup WHERE IPTypeID='" & inputTypeID & "';", dbOpenForwardOnly)
        If Not table.BOF And table.EOF Then ' If the acronym entered is already in use
            table.Close
            MsgBox "IP acronym is already in use!", vbExclamation, "Duplicate IP Acronym"
            Exit Sub
        End If
        table.Close
        Set table = globalDatabase.OpenRecordset("SELECT * FROM IPTypeLookup WHERE Type='" & inputType & "';", dbOpenForwardOnly)
        If table.BOF And table.EOF Then ' If the IP Type entered does not exist
            table.Close
            Set table = globalDatabase.OpenRecordset("IPTypeLookup", dbOpenTable)
            table.AddNew
            table!IPTypeID = inputTypeID
            table!Type = inputType
            table.Update
            table.Close
            DoCmd.Close acForm, Me.Name
        Else ' If the IP Type entered does exist
            table.Close
            MsgBox "IP type already exists!", vbExclamation, "Duplicate IP Type"
        End If
    End If

Exit_Sub:
    Exit Sub

Error_Sub:
    MsgBox err.Description
    Resume Exit_Sub
End Sub

Aoude February 24th, 2006 05:21 PM

how do you find out what line is causing the problem...sorry i'm new at this!!


All times are GMT -4. The time now is 01:11 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.