Hi all!
You were SO VERY HELPFUL with my last request ... everything is working beautifully! You were even helpful on things you didn't know about because as i was typing out my post, I got a few ideas and worked it out myself! So, thanks for those, too!
This time, it's a database for dear hubby.
I've done something very similar in the past that worked perfectly. This time, I think it's due to the sub-form ... maybe?
There are installation details that use certain parts and a particular quantity of that part.
I have a parts table, an detail table (hubby insisted on calling it that) and a link table ... this is all very much like parts and invoices or a recipe and ingredients.
On the Install Detail form, there is a sub-form for the parts. The sub-form has a combo box for the part number, a box to enter the quantity and two locked fields showing the description and size of the part so the user knows it's the correct one.
If the user enters a part number that isn't in the parts table, a message box pops up and asks the user if they want to enter the new part. if they answer "no", another message box prompts them to choose from the list. If they answer "yes", then the Parts form opens with the new part number already populating the Item No. field. But then, a message appears saying "The text you entered isn't an item in the list" ... this is an Access message, not one I programmed. If I could figure out where that was being triggered, I'd add a line to disable the error messages.
After the new part is entered and the Parts form is closed, I'd like the combo-box in the sub-form to requery. But, it's unhappy about that, too!
I've attached the database, but here's the code in case something obvious jumps out:
This is from the sub form when the part number isn't in the list:
Code:
Private Sub Item_No_NotInList(NewData As String, Response As Integer) On Error GoTo Item_No_NotInList_Err
Dim intAnswer As Integer
Dim strNew As String 'didn't end up using this
DoCmd.SetWarnings False
intAnswer = MsgBox("The part number " & Chr(34) & NewData & _
Chr(34) & " is not currently listed." & vbCrLf & _
"Would you like to open the part number form in order to add it now?" _
, vbQuestion + vbYesNo, "B&V BOQ")
If intAnswer = vbYes Then
'open the parts form in add new mode and pass the NewData to the form
DoCmd.OpenForm "frm_Parts", , , , acFormAdd, , NewData
Response = acDataErrAdded
Else
MsgBox "Please choose a part number from the list." _
, vbInformation, "B&V BOQ"
Response = acDataErrContinue
End If
Item_No_NotInList_Exit:
DoCmd.SetWarnings True
Exit Sub
Item_No_NotInList_Err:
MsgBox Err.Description, vbCritical, "Error"
Resume Item_No_NotInList_Exit
End Sub
On the parts form, this is in the On Load event:
Code:
Private Sub Form_Load() 'set the cursor in the item_No text box
Me.Item_No.SetFocus
'check to see if an openargs value was passed from the Parts subform
If Not IsNull(Me.OpenArgs) Then
'if there IS an openargs value, then set the Item_No to equal the NewData
Item_No = OpenArgs
Else
'if there is no openargs value, set the cursor in the Item
Me.Item_No.SetFocus
End If
End Sub
Should I disable the regular Access warnings? if so, where?
I tried code to requery the the Item_No combo box in the sub-form when it had focus, but it wasn't happy with that, so I took it out. Can I requery a sub-form in it's entirety? Yes, I can, but It's still upset that the text in the Item_No combo box isn't in the last ... although with the requery, it actually IS.
When the parts form is closed, I do want the Instal_Detail form to still be on the same Detail.
(and a note: the part numbers and the detail numbers are the primary keys because dear hubby swears up and down there will be no duplicates and he and the other users get a bit anxious when an AutoID number shows up in a field where they were expecting a text part number or detail number. So don't fuss at me about that! )
Thank you!
Susie
Kansas