DoCmd.RunSQL in Access 2007

I have an Access 2007 DB that we are using as a project management/ticket tracking solution.  My boss wants to be able to track how long different groups work on the project so we can start to trend and see where the bottlenecks are.  

So, I have the main table called Issues, and a 2nd table called tblWithGroup.  The structure for tblWithGroup is:

ID (PK),
Issues_ID (FK to Issues table),
Group (linked to Issues table field called with_group),
Start_Date,
End_Date.

The fields in Issues that come in to play are:

with_group (list box with list of groups)
group_ID links to tblWithGroup ID so we can match records
ID (pk)
 
Step 1 should be, look and see if there is already an entry in Issues.group_ID
If not, add a new record to tblWithGroup and update group_ID
If group_ID = tblWithGroup.ID put an end_date THEN add a new record to tblWithGroup and update group_ID

Right now I am trying to do it with docmd.runsql (    DoCmd.RunSQL "UPDATE tblWithGroup SET End_Date = Date() WHERE me!group_ID = tblWithgroup.ID;"), but it doesn't accespt the VB of me!group_ID, and if I put it in, it says you are about to update 1 record.  (got the code attached so you can see the whole thing)



How can I do a WHERE clause in VBA so that it will match group_id to tblwithGroup.ID and update the record?

I'm brand new to access and programming in general, so I am hoping I'm making sense!
COSMTARFCUAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

COSMTARFCUAuthor Commented:
apparently I forgot to add the code, so here it is...sorry!
Private Sub with_group_AfterUpdate()

Stop

Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("tblWithGroup")

With rs

If Me!group_ID = Null Then
    Me!group_ID = Null
   Else
    DoCmd.RunSQL "UPDATE tblWithGroup SET End_Date = Date() WHERE me!group_ID = tblWithgroup.ID;"
    .Edit
    
End If

    .AddNew
    !Issue_ID = Me.ID
    !Group = Me.with_group
    !Start_Date = Date
    Me!group_ID = ID
    .Update
End With

If Not rs Is Nothing Then
    rs.Close
    Set rs = Nothing
End If

Exit Sub

End Sub

Open in new window

sameer2010Commented:
Hi,

Concatenate me!group_ID before executing the command.


dim s as string
s = "UPDATE tblWithGroup SET End_Date = Date() WHERE tblWithgroup.ID= " + me!group_ID  + ";"
DoCmd.RunSQL s

Open in new window

COSMTARFCUAuthor Commented:
Thanks.  When I tried that, it still asks me to enter parameter value Me!group_ID?
Is there a different way to do a Where clause in vba instead of doing the docmd.runsql?
Thanks for the help!
COSMTARFCUAuthor Commented:
Actually, saw a typo in my code...but I do get a type mismatch. error now.
 
tblWithGroup.ID is an autonumber, and issues.group_ID is a Number.  Any way around that?
sameer2010Commented:
if group_id is a number, fir convert it to string for concatenation.
dim s as string
s = "UPDATE tblWithGroup SET End_Date = Date() WHERE tblWithgroup.ID= " + Str(me!group_ID)  + ";"
DoCmd.RunSQL s

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.