token_remedie
Registered User.
- Local time
- Today, 23:07
- Joined
- Jul 7, 2011
- Messages
- 78
basically I've built an asset management db but when an asset gets redistributed I want to add it to the redistribution table with a yes\true value in the check field so that the next form can find that value and add the current location to it and then update the deployed (main table) table with the new location. i hope that makes sense, it runs but doesn't check the box, I'm using access 2007 I'm a bit of a noob but here's my code:
Public Sub Command101_click()
Dim SQL As String
'this part definitely works
SQL = "INSERT INTO redistributed([asset number],[Asset Description],[serial no],[Invent No])VALUES('" & Item & "','" & [Asset Description] & "','" & [Serial No] & "','" & [Invent No] & "')"
'this runs but doesn't check the box i want it to, i've tried 0,-1, true false, yes\no
If (SQL = "Select redistributed.check,residtributed.[asset number] From redistributed redistribued.check WHERE redistributed.[asset number] = [FORMS]![asset details]![item] and redistributed.check = no") Then
SQL = "UPDATE redistributed SET redistributed.check = yes"
Else: If (SQL = "Select redistributed.check,residtributed.[asset number] From redistributed redistribued.check WHERE redistributed.[asset number] = [FORMS]![asset details]![item] and redistributed.check = -1") Then MsgBox ("already relocated")
End If
CurrentDb.Execute SQL
DoCmd.OpenForm "redistlocation", , , "[Forms]![Asset Details]![Item]=" & Me![Asset Number]
End Sub
Public Sub Command101_click()
Dim SQL As String
'this part definitely works
SQL = "INSERT INTO redistributed([asset number],[Asset Description],[serial no],[Invent No])VALUES('" & Item & "','" & [Asset Description] & "','" & [Serial No] & "','" & [Invent No] & "')"
'this runs but doesn't check the box i want it to, i've tried 0,-1, true false, yes\no
If (SQL = "Select redistributed.check,residtributed.[asset number] From redistributed redistribued.check WHERE redistributed.[asset number] = [FORMS]![asset details]![item] and redistributed.check = no") Then
SQL = "UPDATE redistributed SET redistributed.check = yes"
Else: If (SQL = "Select redistributed.check,residtributed.[asset number] From redistributed redistribued.check WHERE redistributed.[asset number] = [FORMS]![asset details]![item] and redistributed.check = -1") Then MsgBox ("already relocated")
End If
CurrentDb.Execute SQL
DoCmd.OpenForm "redistlocation", , , "[Forms]![Asset Details]![Item]=" & Me![Asset Number]
End Sub