Results 1 to 5 of 5

Thread: conversion

  1. #1
    Join Date
    Aug 2003
    Location
    London,UK
    Posts
    54

    Unanswered: conversion

    i have got a table with an autonumber as the key.

    when the form is loaded it creates a new record in the table, displays the id in a text box and closes the connection.

    when the cancel button is pressed i want it to delete the record but using the following sql i get a data mismath error.

    Dim strsql As String
    strsql = "SELECT * FROM projectHeader " & _
    "WHERE projectID = '" & txtCNPProjectID.Value & " ' "
    createRecordset (strsql)
    rs.Delete
    rs.Update
    DoCmd.Close

    how can i convert the txtCNPProjectID.Value wich is showing an intger value into an integer?

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    your & _ may not be having the effect you anticipate. try:

    Code:
    strsql = "SELECT * FROM projectHeader " 
    strsql = strsql & "WHERE projectID = '" & txtCNPProjectID.Value & "';"
    note the trailing ; as well.

    izy

  3. #3
    Join Date
    Aug 2003
    Location
    London,UK
    Posts
    54
    the & _ works fine i have checked this, what does the ; do?

    the problem is that txtCNPProjectID.Value returns a text value. However the the value in there is actually a collection of digits ie 14445.

    this i need to convert 14445 text to 14445 integer so i can use it in the sql as the projectID is an autonumber.

  4. #4
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    try:
    "WHERE projectID = " & txtCNPProjectID.Value & ";"

    the "'" text "';" construction is to concatenate quoted text into your string.

    izy

  5. #5
    Join Date
    Aug 2003
    Location
    London,UK
    Posts
    54
    thank you that works a fine.

Posting Permissions

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