July 2, 2005 at 5:13 pm
Hi,
Access VBA is baffling my mind. I'll give you the full details below, but the gist of the problem is when I insert a record programetically into a table using ADO, and open a form that uses that table as its record source, the new record doesn't show up until I close the form and open it again. Even the record count is off: when I programetically open the form it shows 877 records, when I manually close it and open it again it shows 878.
Here's the details of my problem, read on if you care to...
I'm doing a marketing database for a consulting firm. They need to keep track of Opportunities, Proposals and Projects. Here is a simplified data schema...
As you can see, each Opportunity CAN lead to 1 or more proposals, but it doesn't have to (in reality only about 1/3 do). The same situation exists with Proposals to Projects.
Some of you who work for yourself may find this familiar. Anyway, in tbl_Opportunities, the OpportunityStatus field is a Combo box. The possible statuses are 'New Opportunity', 'Undecided', 'Passed', and 'Proposal'. The onChange event for that combo box checks to see if the new value is 'Proposal'. If it is, it
Here is the VBA code that is supposed to do that...
'Check to see if there already is a proposal (omited)
cnxn.Open CurrentProject.Connection
Dim cmdCommand As New ADODB.Command
cmdCommand.ActiveConnection = cnxn
cmdCommand.CommandText = "INSERT INTO tblProposals " _
cmdCommand.Execute
Set cmdCommand = Nothing
cnxn.Close
Set cnxn = Nothing
DoCmd.OpenForm "Proposals"
DoCmd.GoToRecord , , acLast
The first part of the code works fine, the record is inserted, but 99% of the time the second part does not take the user to the record that was just inserted, as I mentioned above, the record count is off until I close the form and re-open it.
DoCmd.FindRecord OID, , , , acSearchAll, , acCurrent
DoCmd.Close acForm, "MainFormOpps"
July 3, 2005 at 12:05 pm
Please do not cross-post.
Finish the thread here : http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=131&messageid=196547
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply