"Add Item" Button

Chrisopia

Registered User.
Local time
Today, 11:58
Joined
Jul 18, 2008
Messages
279
I am having trouble creating a code for a button to add a new item,

basically it will save all the data, wipe the form clean but keeping the CustomerID and OrderID the same, and the DescriptionID should go up 1?

Any ideas?

Code:
Private Sub newitem_Click()
DoCmd.RunCommand acCmdSaveRecord
Dim Loc2 As String
Dim Loc3 As String
Loc2 = Me![Wizard step 2 b].Form![CustomerID]
Loc3 = Me![Wizard step 2 b].Form![OrderID]
DoCmd.OpenForm "Wizard step 2 Inv", acNormal, , "[CustomerID]=" & Loc2 & "AND" & "[OrderID]=" & Loc3
End Sub

Here's what I have so far which is wrong on many levels. For a start I'm using a "Open Form" thingy, and I cant think of a different way around it.
And when I click on it the entire form is blank!?

Is it a "goto NewRec" source I'm after perhaps? If so how would I maintain the same customerID and OrderID when this happens??

Perhaps it is the NewRec, in which case I suppose it's like any navigation buttons... I will need the option to go backward and forwards also to ammend previous things on the same OrderID... does this make sense?
 
Right so I have been playing around with the goTo New Record function but I cant seem to get it right.

I now realise I am aiming for a subform, within a subform
(Wizard step 2a is within Wizard step 2b)

I keep getting an error telling me "Wizard step 2a isn't open"

Code:
 DoCmd.GoToRecord acDataForm, "Me![Wizard step 2 b].Form![Wizard step 2 a]", acNewRec

There's that one and the other error "is the wrong data type for one of the arguments.

Code:
DoCmd.GoToRecord acDataForm, Me![Wizard step 2 b].Form![Wizard step 2 a], acNewRec

Also if I could reference this properly, the OrderID on Wizard step 2 a needs to be the same as Wizard step 2 b!?
 

Users who are viewing this thread

Back
Top Bottom