Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

Dcount problem when using text characters?

Discussion in 'Information Technology' started by midiman69, Jul 28, 2006.

  1. midiman69

    midiman69
    Expand Collapse
    Guest

    I have a problem with

    If DCount("*", "tblnewparts", "partno = '" & partno & "'") = 0 Then
    If MsgBox("This is a New Part - Do You Wish To Add?", vbYesNo, "Project
    Costing Database") = vbNo Then
    Cancel = True
    Me.Undo
    Exit Sub

    Else: DoCmd.RunSQL "INSERT INTO tblnewparts ( partno, xfile, issue ) " _
    & "Values ('" & partno & "', '" & Forms!frmprojectstabbed.Form!xfile
    & "', '" & Forms!frmprojectstabbed.Form!issue & "')"

    Cancel = True
    Me.Undo


    End If

    End If

    This works fine for part numbers such as 20025 but When using part number
    that contain characters such as / and - eg 35006/H or 041-03729A the code
    recognises these as "new parts" while in fact they are existing parts with
    matching records - The partno field is text - Can any one help?

    Also when using paste append to import data from excel all part numbers
    trigger the new part dialogue - why is this?
     
  2. Loading...

    Similar Threads Forum Date
    Sikh News Sikhs Face Problems While Carrying Kirpans In Khyber-Pakhtunkhwa - SikhSiyasat.Net Breaking News Jul 29, 2016
    "Dasam" Granth - A Look At The Core Problems Dasam Granth Oct 21, 2015
    Problems In Life Sikh Sikhi Sikhism Apr 13, 2015
    How can I make decent and useful friends and from where ?? most people have a problem with me Sikh Youth Oct 23, 2013
    The Problem with Taking Too Many Vitamins Health & Nutrition Oct 18, 2013

  3. Yanick

    Yanick
    Expand Collapse
    Guest

    Did you try to trim your part number to remove extra space before and after
    the part? (Trim(YourPart))

    I also know that excel add ' before text cell in some occasion to represent
    text. (And it is not visible in excel by default, you have to select the cell
    and edit it to see the ' character) It may be your problem.

    I have look at your code and it seems correct. You mentioned your part
    number field is text so should work. There will be a difference in the SQL if
    you need compare both text and number but that is not your case.

    Hope it will help.

    "midiman69" wrote:

    > I have a problem with
    >
    > If DCount("*", "tblnewparts", "partno = '" & partno & "'") = 0 Then
    > If MsgBox("This is a New Part - Do You Wish To Add?", vbYesNo, "Project
    > Costing Database") = vbNo Then
    > Cancel = True
    > Me.Undo
    > Exit Sub
    >
    > Else: DoCmd.RunSQL "INSERT INTO tblnewparts ( partno, xfile, issue ) " _
    > & "Values ('" & partno & "', '" & Forms!frmprojectstabbed.Form!xfile
    > & "', '" & Forms!frmprojectstabbed.Form!issue & "')"
    >
    > Cancel = True
    > Me.Undo
    >
    >
    > End If
    >
    > End If
    >
    > This works fine for part numbers such as 20025 but When using part number
    > that contain characters such as / and - eg 35006/H or 041-03729A the code
    > recognises these as "new parts" while in fact they are existing parts with
    > matching records - The partno field is text - Can any one help?
    >
    > Also when using paste append to import data from excel all part numbers
    > trigger the new part dialogue - why is this?
    >
     

Share This Page