Record entry on an unbound form

J

jjstccean

Hi - please assist me with this?:

I have two tables - the 1st table is standard and receiving records
I'm entering and saving records from an unbound form. The second table
receives the new (next) Quote Number which goes into the QuoteNum
field together with other related fields. On the 2nd table the
QuoteNum field has an "Yes (No Duplicates)" setting.

This is the part of my CODE that saves the relevant record to my 2nd
table: an extract:

number exist? yes, goto next set of code:

number exist? no, then

If rStSaveInvNum.RecordCount <> 0 Then

With rStSaveInvNum
rStSaveInvNum.AddNew
rStSaveInvNum!InvoiceNextNum = Me.QuoteNumber
rStSaveInvNum!ClientID = Me.RelateToClient
rStSaveInvNum!InvNumDate = Me.QuoteDate
rStSaveInvNum.Update
rStSaveInvNum.Close
End With
End If

next set of code:

The problem I'm facing is that I'm not certain how to do code —
overlooking the fact that if the Quote Number already exist not to
attempting to add the number again — as I'm using the same Quote
Number for several lines at times. Then again, to add the new Quote
Number and related fields as the new Quote Number does not exist in
2nd table yet.
 
K

Klatuu

You can handle the second table like the first. You just need to decide,
based on how your form works, where to put the code to populate and update
the second table. It would be just another recordset.

Is there any specific reason you are using unbound forms? It sure is a lot
more work that way. If your two tables are related, a good old form/subform
would be the way to go.

Also, I noticed something in your code. When you use the With End With
construct, you don't need to repeat the name of the With object. All you
need is:


With rStSaveInvNum
If .RecordCount <> 0 Then
.AddNew
!InvoiceNextNum = Me.QuoteNumber
!ClientID = Me.RelateToClient
!InvNumDate = Me.QuoteDate
.Update
.Close
End If
End With
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top