Welcome to dbForumz.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

New Record Problem

 
   Database Forums (Home) -> MS Access RSS
Next:  INSERT and foreign key constraints  
Author Message
Bob Vance

External


Since: May 14, 2008
Posts: 120



(Msg. 1) Posted: Thu Jan 01, 2009 5:25 pm
Post subject: New Record Problem
Archived from groups: microsoft>public>access (more info?)

When I open a new record I am not gettting the next number if I select " If
fraSelectInvoiceNoType = 1 "
I am getting a zero , Thanks for any help.............Bob

If Me.NewRecord = True Then
If fraSelectInvoiceNoType = 1 Then
recInvoice.Fields("InvoiceNo") = NextInvoiceNo
ElseIf fraSelectInvoiceNoType = 2 Then
recInvoice.Fields("InvoiceNo") = 0
End If
------------------------------------------------
Function NextInvoiceNo() As Long
NextInvoiceNo = Nz(DMax("InvoiceNo", "tblInvoice"), 0) + 1
End Function

--
Thanks in advance for any help with this......Bob
MS Access 2007 accdb
Windows XP Home Edition Ver 5.1 Service Pack 3

 >> Stay informed about: New Record Problem 
Back to top
Login to vote
Tom Wickerath

External


Since: Nov 09, 2007
Posts: 139



(Msg. 2) Posted: Thu Jan 01, 2009 5:25 pm
Post subject: RE: New Record Problem [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Hi Bob,

What do you get if you issue this command directly from the Immediate Window?

?Nz(DMax("InvoiceNo", "tblInvoice"), 0) + 1

Open the Immediate Window by pressing the Control and G keys at the same
time, ie. <Ctrl><G>.

Also, are you sure that you haven't already saved the record at this point
in time? If you have, then Me.NewRecord will evaluate to False. You might try
inserting a break point, and single stepping through the code using the F8
key.


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________

"Bob Vance" wrote:

> When I open a new record I am not gettting the next number if I select " If
> fraSelectInvoiceNoType = 1 "
> I am getting a zero , Thanks for any help.............Bob
>
> If Me.NewRecord = True Then
> If fraSelectInvoiceNoType = 1 Then
> recInvoice.Fields("InvoiceNo") = NextInvoiceNo
> ElseIf fraSelectInvoiceNoType = 2 Then
> recInvoice.Fields("InvoiceNo") = 0
> End If
> ------------------------------------------------
> Function NextInvoiceNo() As Long
> NextInvoiceNo = Nz(DMax("InvoiceNo", "tblInvoice"), 0) + 1
> End Function
>
> --
> Thanks in advance for any help with this......Bob
> MS Access 2007 accdb
> Windows XP Home Edition Ver 5.1 Service Pack 3

 >> Stay informed about: New Record Problem 
Back to top
Login to vote
Bob Vance

External


Since: May 14, 2008
Posts: 120



(Msg. 3) Posted: Thu Jan 01, 2009 7:25 pm
Post subject: Re: New Record Problem [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

This is the [Close] Button Code..........Thanks Bob

Private Sub cmdClose_Click()
On Error GoTo Err_Command80_Click
If IsNull(Me.tbInvoiceDate) Then

Me!tbInvoiceDate = DateSerial(Year(Date), Month(Date) + 1, 1)


End If

If Len([cbOwnerName]) = 0 Then
MsgBox "Please Select The Horse Name From The List.",
vbApplicationModal + vbInformation + vbOKOnly, "Intellisoft"
Exit Sub
End If

If Len([cbGSTOptions]) = 0 Then
MsgBox "Please Select The GST Options From The List.",
vbApplicationModal + vbInformation + vbOKOnly, "Intellisoft"
Exit Sub
End If


If bModify = True Then
CurrentProject.Connection.Execute "DELETE * FROM
tblDailyCharge WHERE InvoiceID=" & tbInvoiceID.value
CurrentProject.Connection.Execute "DELETE * FROM
tblAdditionCharge WHERE InvoiceID=" & tbInvoiceID.value
bModify = False
End If
subSetValues
subSetInvoiceDetailsValues
recInvoice.Update

Set recInvoice = Nothing
Forms!frmModifyInvoiceClient!lstModify.Requery
DoCmd.Close acForm, Me.Name

Exit Sub
Exit_Command80_Click:
Exit Sub

Err_Command80_Click:
MsgBox Err.Description
Resume Exit_Command80_Click

End Sub
"Tom Wickerath" <AOS168b AT comcast DOT net> wrote in message

> Hi Bob,
>
> What do you get if you issue this command directly from the Immediate
> Window?
>
> ?Nz(DMax("InvoiceNo", "tblInvoice"), 0) + 1
>
> Open the Immediate Window by pressing the Control and G keys at the same
> time, ie. <Ctrl><G>.
>
> Also, are you sure that you haven't already saved the record at this point
> in time? If you have, then Me.NewRecord will evaluate to False. You might
> try
> inserting a break point, and single stepping through the code using the F8
> key.
>
>
> Tom Wickerath
> Microsoft Access MVP
> http://www.accessmvp.com/TWickerath/
> http://www.access.qbuilt.com/html/expert_contributors.html
> __________________________________________
>
> "Bob Vance" wrote:
>
>> When I open a new record I am not gettting the next number if I select "
>> If
>> fraSelectInvoiceNoType = 1 "
>> I am getting a zero , Thanks for any help.............Bob
>>
>> If Me.NewRecord = True Then
>> If fraSelectInvoiceNoType = 1 Then
>> recInvoice.Fields("InvoiceNo") = NextInvoiceNo
>> ElseIf fraSelectInvoiceNoType = 2 Then
>> recInvoice.Fields("InvoiceNo") = 0
>> End If
>> ------------------------------------------------
>> Function NextInvoiceNo() As Long
>> NextInvoiceNo = Nz(DMax("InvoiceNo", "tblInvoice"), 0) + 1
>> End Function
>>
>> --
>> Thanks in advance for any help with this......Bob
>> MS Access 2007 accdb
>> Windows XP Home Edition Ver 5.1 Service Pack 3
 >> Stay informed about: New Record Problem 
Back to top
Login to vote
Bob Vance

External


Since: May 14, 2008
Posts: 120



(Msg. 4) Posted: Thu Jan 01, 2009 7:25 pm
Post subject: Re: New Record Problem [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Oh Got it GREAT, Changed the close button to another subSetValues() with
another name and deleted out the Invoice Number Code........Brilliant Im
getting better Thanks.......Bob Smile


"Tom Wickerath" <AOS168b AT comcast DOT net> wrote in message

> Hi Bob,
>
> What do you get if you issue this command directly from the Immediate
> Window?
>
> ?Nz(DMax("InvoiceNo", "tblInvoice"), 0) + 1
>
> Open the Immediate Window by pressing the Control and G keys at the same
> time, ie. <Ctrl><G>.
>
> Also, are you sure that you haven't already saved the record at this point
> in time? If you have, then Me.NewRecord will evaluate to False. You might
> try
> inserting a break point, and single stepping through the code using the F8
> key.
>
>
> Tom Wickerath
> Microsoft Access MVP
> http://www.accessmvp.com/TWickerath/
> http://www.access.qbuilt.com/html/expert_contributors.html
> __________________________________________
>
> "Bob Vance" wrote:
>
>> When I open a new record I am not gettting the next number if I select "
>> If
>> fraSelectInvoiceNoType = 1 "
>> I am getting a zero , Thanks for any help.............Bob
>>
>> If Me.NewRecord = True Then
>> If fraSelectInvoiceNoType = 1 Then
>> recInvoice.Fields("InvoiceNo") = NextInvoiceNo
>> ElseIf fraSelectInvoiceNoType = 2 Then
>> recInvoice.Fields("InvoiceNo") = 0
>> End If
>> ------------------------------------------------
>> Function NextInvoiceNo() As Long
>> NextInvoiceNo = Nz(DMax("InvoiceNo", "tblInvoice"), 0) + 1
>> End Function
>>
>> --
>> Thanks in advance for any help with this......Bob
>> MS Access 2007 accdb
>> Windows XP Home Edition Ver 5.1 Service Pack 3
 >> Stay informed about: New Record Problem 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
how can i use next record from other last record field in .. - i have 2 field, previous value and next value. The 1st record from previous value is keyin manually, while present value are keyin manually everytime. But the next record for previous value is getting from the last record of present value. how can i....

number record of record - I have a form(f2PlantUnit) with a subform(f3UnitSub) linked by the field ProjectID On the subform, I have the arrows that go First, Previous, Next, Last record. I would like to show ... 1 of 2 ...if they are on record 1 of 2 records. .... next...

RECORD - Hello all.... I have finally put everything together in the database and now have one final issue, I think :) But, how do I create a command button that will bring up a record based on the ID number?? Thanks!! Ransom

Record switch - I was in the process of populating three records with a form. When I came back into the database. The records were switched around. Record 3 became one, record 2 became threen, and record 1 became 2. Please advise. -- thanks

Checking for new record - Hi I need to validate a field in after update but only if it is a new record and not an exiting record. How can I check for a new record in after update event of a field? Thanks Regards
   Database Forums (Home) -> MS Access All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]