Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2005
    Posts
    9

    Unanswered: Which value to set for a text box?

    Dear All,

    I have an Access application which could be run on Access or SQL Server as a backend. I need to clear a value of a text box, so I set Me.txtStudentID = Null. That is fine in Access but it generate an error in SQL Server, try to assign a Null to a variable not variant type. I change the code to Me.txtStudentID = "". This time it works fine in SQL Server, but it generates an error in Access, "Field 'STUDENT.NAME' cannot be a zero-length string."
    I do not know which value I should set to that text box so it will be OK in Access and SQL Server. Please, give me some advice.

    Thank you.

  2. #2
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    Here's 1 option:
    You need to go into your table set up in SQL Server. Change the Nullable property for the field in your table to true.
    Inspiration Through Fermentation

  3. #3
    Join Date
    Feb 2005
    Posts
    9
    Unfortunately, that field is a primary key, no null allowed.
    Any suggestions?

    Thank you.

  4. #4
    Join Date
    May 2005
    Posts
    1,191
    Can you change the zero-length property in the table in Access, or is it the same story?
    Me.Geek = True

  5. #5
    Join Date
    Feb 2005
    Posts
    9
    You are right Nick. What I did is what you just said.

    Thank you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •