Results 1 to 3 of 3
  1. #1
    mar_t is offline Advanced Beginner
    Windows XP Access 2002
    Join Date
    Nov 2010
    Posts
    52

    How to declare a field as an interger/number

    Hi,



    I get a "run-time error "3464" everytime I Add, Update and Delete a record based on GroupID. In my table the data type for GroupID is number and the other two fields are text. I would like to know how to declare my GroupID filed as an interger or number? BTW, i have no idea about VBA :-) ..please help.


    Code:
      Option Compare Database
      Option Explicit
      Dim sql As String
       
      Private Sub cmdAdd_Click()
      sql = "INSERT INTO tblGroup(GroupID,Section,Unit) " & "VALUES ('" & GroupID & "','" & txtSection & "','" & txtUnit & "')"
      DoCmd.RunSQL (sql)
      lst1.Requery
      End Sub
       
      Private Sub cmdDelete_Click()
      sql = "DELETE FROM tblGroup WHERE GroupID = '" & GroupID & "'"
      DoCmd.RunSQL (sql)
      lst1.Requery
      End Sub
       
      Private Sub cmdUpdate_Click()
      sql = "UPDATE tblGroup SET GroupID = '" & GroupID & "', Section = '" & txtSection & "', Unit = '" & txtUnit & "' WHERE GroupID = '" & lst1.Column(0) & "'"
      DoCmd.RunSQL (sql)
      lst1.Requery
      End Sub
       
      Private Sub lst1_Click()
      GroupID = lst1.Column(0)
      txtSection = lst1.Column(1)
      txtUnit = lst1.Column(2)
       
      End Sub

  2. #2
    maximus's Avatar
    maximus is offline Expert
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    to start with while updating number Fields the values should not be enclosed in ' ' which is only required for Text values.

    so assuming GroupId is number your sql should look like this:

    “Insert into tblGroup(GroupID,Section,Unit) Values (“ & Me.GroupID & “,’” & txtSection & “’,’” & txtUnit &”')"


    Remember dates have to be enclosed by #

  3. #3
    mar_t is offline Advanced Beginner
    Windows XP Access 2002
    Join Date
    Nov 2010
    Posts
    52
    All my command buttons are now working, thank you for all the help.

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

Similar Threads

  1. Declare a Global Variable and Use it on Forms
    By jackkent in forum Access
    Replies: 9
    Last Post: 10-07-2010, 10:19 AM
  2. Replies: 2
    Last Post: 06-23-2010, 06:37 PM
  3. Field displays number instead of value
    By rdueck in forum Reports
    Replies: 6
    Last Post: 02-25-2010, 08:19 PM
  4. about number field in table
    By spradhan in forum Access
    Replies: 1
    Last Post: 02-19-2010, 12:44 PM
  5. How to Increment A Number Field
    By Advanced in forum Programming
    Replies: 3
    Last Post: 01-27-2010, 02:36 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