Results 1 to 2 of 2
  1. #1
    hardik_088 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2011
    Posts
    2

    Update value with dcount

    hi guys,
    i have laptops form and that has description,[quantity ordered],location,[suggested supplier] ,[part number] fields and i have form "Insert_data" that have textbox and i want to insert data and also want to check this fields descritption,[suggested supplier],[quantity ordered],[part number],location and if same data is there in table then it should update otherwise insert new data and i have tried following code but when it is checking fields it is checking just description field and updating or inserting data So what i should do to check that fields.

    If (Forms!Insert_Data![Type].Value = "Laptops") Then

    If DCount("Description", "Laptops", "Description = " & Chr(34) & Forms!Insert_Data.Description & Chr(34)) > 0 Then
    If DCount("Location", "Laptops", "Location = " & Chr(34) & Forms!Insert_Data.Location & Chr(34)) > 0 Then
    If DCount("[part number]", "Laptops", "[part number] = " & Chr(34) & Forms!Insert_Data.[part number] & Chr(34)) > 0 Then
    DoCmd.RunSQL "UPDATE Laptops SET Laptops.[quantity ordered] = Laptops.[quantity ordered] + " & Forms!Insert_Data![quantity ordered] & " WHERE Laptops.Description = " & Chr(34) & Forms!Insert_Data.Description & Chr(34)
    DoCmd.Close acForm, "Insert_Data"
    End If
    End If
    Else

    DoCmd.RunSQL "INSERT INTO Laptops ([requsition type],[type],[purchase requisition],Location,department,requestor,[suggested supplier],[quantity ordered],[part number] ,Description,[privincial tracking number],[po number],[status],[billing code],[itscc code],[itscc task number]) " & _
    " VALUES (" & Chr(34) & Forms!Insert_Data![requsition type].Value & Chr(34) & "," & Chr(34) & Forms!Insert_Data![Type].Value & Chr(34) & "," & Chr(34) & Forms!Insert_Data![purchase requisition].Value & Chr(34) & "," & Chr(34) & Forms!Insert_Data!Location.Value & Chr(34) & ", " & Chr(34) & Forms!Insert_Data![Department].Value & Chr(34) & "," & Chr(34) & Forms!Insert_Data!Supplier.Value & Chr(34) & "," & Chr(34) & Forms!Insert_Data![Requestor].Value & Chr(34) & "," & Forms!Insert_Data![quantity ordered].Value & "," & Chr(34) & Forms!Insert_Data![part number].Value & Chr(34) & "," & Chr(34) & Forms!Insert_Data!Description.Value & Chr(34) & ", " & _
    " " & Chr(34) & Forms!Insert_Data![privincial tracking number].Value & Chr(34) & "," & Chr(34) & Forms!Insert_Data![po number].Value & Chr(34) & "," & Chr(34) & Forms!Insert_Data![Status].Value & Chr(34) & "," & Chr(34) & Forms!Insert_Data![billing code].Value & Chr(34) & "," & Chr(34) & Forms!Insert_Data![itscc code].Value & Chr(34) & "," & Chr(34) & Forms!Insert_Data![itscc task number].Value & Chr(34) & ")"

    End If



    Thanks you very much

  2. #2
    hardik_088 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2011
    Posts
    2
    hi guys,
    Dcount[description] part is working. if I use both Dcount[location] and Dcount[part number] then not working but if I use just one at a time then its working . I dont know why its not working . Can anybody help me.


    Thanks,

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

Similar Threads

  1. DSum or DCount
    By vdanelia in forum Forms
    Replies: 1
    Last Post: 03-01-2011, 03:59 AM
  2. Dcount question
    By jpkeller55 in forum Access
    Replies: 4
    Last Post: 02-21-2011, 11:43 AM
  3. DCount and SQL
    By DSTR3 in forum Queries
    Replies: 3
    Last Post: 12-06-2010, 03:07 PM
  4. multiple dcount update query
    By slothnet in forum Programming
    Replies: 5
    Last Post: 08-24-2010, 03:44 PM
  5. Help with Dcount
    By tozey in forum Programming
    Replies: 1
    Last Post: 08-10-2010, 10:53 AM

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