Help With New Record Comman Button

D

Damon Johnson

Hi All!
I apologize if this is a duplicate. Having problems with OE
Access XP on Win XP Pro

I've been struggling 2 months on and off with this. This is somewhat
complicated for me to explain, so I REALLY appreciate your
patience and knowledge...

I have a bound form named frmFlintXRef.
On the form I have several textboxes, command buttons and combo boxes, as
follows;

cmdNEWFLINTNO (command button to enter new part number)
cbxCAT (combo box containing several categories from the CATEGORIES field)
ST,DR, RT, FR, DE, etc.
txtFID (a text box which is an autonumber field)1, 2, 3, etc..
txtFLINTNO (a text box which, after a category is selected from cbxCAT, is a
concatenation of the CATEGORIES and FID field) example ST-657
Several other text and combo boxes

What I would like to happen is this;
A user clicks on cmdNEWFLINTNO
The fields go blank, ready to accept a new record- So far this is no problem
The user selects a category from cbxCAT (ST)
After the user selects a category this generates the next autonumber in line
(658)
Then I want txtFLINTNO to show the resulting value, ST-658. Which in code
should look like this

I know I could use the AfterUpdate event for cbxCAT and place this code in
it;
txtFLINTNO.Value = [CAT] & "-" & [FID]

But doing so would mean that everytime someone changed the category for an
existing record, it would generate a new number, changing/deleting the
existing number altogether.

What would be ideal is for the user to click the cmdNEWFLINT button first,
then after the user selects a category, the code above in the cbxCAT
AfterUpdate event executes.
I've tried unsuccessfully placing the code in a module and using the Call
keyword. It does not work. Here's what I have;

Thank you TREMENDOUSLY for your time considering this
Damon Johnson

Private Sub cmdNEWFLINTNO_Click()
Call CAT_AfterUpdate
On Error GoTo Err_cmdNEWFLINTNO_Click
DoCmd.GoToRecord , , acNewRec
Exit_cmdNEWFLINTNO_Click:
Exit Sub
Err_cmdNEWFLINTNO_Click:
MsgBox Err.Description
Resume Exit_cmdNEWFLINTNO_Click

End Sub

This is the procedure being called in Private Sub cmdNEWFLINTNO. It's
located in a Module named Module2;

Public Sub CAT_AfterUpdate()
Forms!frmFlintXRef.CAT.SetFocus
Forms!frmFlintXRef!FLINTNO.Value = Forms!frmFlintXRef.CAT & "-" &
Forms!frmFlintXRef.FID
Forms!frmFlintXRef.RECNO.Value = Forms!frmFlintXRef.FID

End Sub
 

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