Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADDING NEW DATA ERROR

Status
Not open for further replies.

niteraven

Technical User
Oct 26, 2006
92
US
Hi All,

I have been using the same code to add a new item to a combobox list for over 7 years. Now i am getting a weird result, the form goes to a new record (every field is blank). You can use scroll on mouse and go back to the original record. (I have compiled my code)

I searched and found a few good changes to try, one Remou's and one theAceman1. But i have the form based on input from the user ( user inputs the sales order number) and when i try either of the suggestions, the user would have to input the sales order # again.

I have a lot of code behind this form, it is the first messaging database i have made, so maybe it is flaking out because of other code i have within the form. Has anyone ran into this problem before?

Here is the code:
Code:
Dim db As DAO.Database
    
        
    If MsgBox("SALESMAN'S NAME IS NOT IN THE LIST.  WOULD YOU LIKE TO ADD IT?", vbYesNo, "UNKNOWN SALESMAN NAME") = vbYes Then
        
        Set db = CurrentDb()
        db.Execute "Insert into tblsman ([salesmanname]) values ('" & NewData & "');"
        Response = acDataErrAdded
        
    Else
        
        Response = acDataErrContinue
        
    End If
    
    Set db = Nothing

It is short and sweet and i am certain i got this code orginally from this forum years ago. This code is working in 4 other forms in this database just fine.


Any help would be appreciated.
Raven
 
How are ya niteraven . . .

Sounds like something with the combo has been corrupted!

Delete & reconstitute the combo . . .

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Hi Ace,

I have done that 3 times, each time after deleting the combo and code behind it, compiling.

Still no luck

THanks
Raven
 
Niteraven,

Have you tried compacting and repairing?


Ian Mayor (UK)
Program Error
9 times out of 10 I know what I'm talking about. This must be my tenth reply.
 
Thanks Ian I did that and it didnt make a difference.

But i figured out what it was, the combobox was last on the tab order, therefore it went to a new record when i tabbed out of it. (BLUSH) geez oh pete. The easiest thing and i spent 2 hours on it. I really do have common sense.

So for future reference, i put in what i did wrong.

THanks all
Raven
 
Have a look at the Cycle property of your form.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top