Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 358
  • Last Modified:

Adding new user to Access database not working

Im having a problem when adding a new user to my Access database. For some reason it is saying that 'action cancelled by an associated object' and debugging at 'data1.recordset.update'. I have looked through the code and cannot figure it out. Any help would be much apreciated. Heres the code:


If Text1.Text = "" Or Text3.Text = "" Then
            MSG = "Please enter Username, employee type and password of new user"    ' Define message.
            Style = vbExclamation                      ' Define buttons.
            Title = "Enter details"                 ' Define title.
            responce = MsgBox(MSG, Style, Title)
            Text1.SetFocus
            'Data1.Recordset.MoveFirst
            cmdOk.Enabled = False
            Command7.Enabled = True
            Command1.Enabled = False
            Command2.Enabled = False
       
        ElseIf Text4.Text = Text3.Text Then
                Data1.Recordset.Update
                Data1.Refresh
                MsgBox ("User added")
                cmdOk.Enabled = False
                Text4.Text = ""
                Text1.Locked = True
                Text2.Locked = True
                Text3.Locked = True
                Text4.Locked = True
            Else
                MsgBox ("Confirmed password incorrect. Please confirm again")
                Text3.Text = ""
                Text4.Text = ""
                Text3.SetFocus
                Command1.Enabled = False
                Command2.Enabled = False
    End If

Thanks
0
matt_fennell
Asked:
matt_fennell
  • 4
  • 4
  • 2
1 Solution
 
mlmccCommented:
Where do you put the recordset into ADDNEW mode?

mlmcc
0
 
bhagyeshtCommented:
have u written Data1.Recordset.AddNew ?
0
 
matt_fennellAuthor Commented:
Yes. That piece of code is in a seperate command button. I have an add command, then the necessary data is added. But when you click cmdok, where the update is stored, it gives me the error msg.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
mlmccCommented:
Are the controls bound?  Are you storing the passwords in clear text?

mlmcc
0
 
matt_fennellAuthor Commented:
Data control is bound. And text uses a '*' for password char
0
 
mlmccCommented:
I just ran into something similar today while building an application to update an MS SQL table.

I don't recall the exact error message but it was similar.  The problem was one of the fields I was updating was too short for the data I was trying to insert. I updated the field definition to be long enough and the problem went away.

Verify the password or username or employee type isn't too long.  Also verify you aren't trying to insert a NULL into a nonnullable field.

Password in the clear?
I was referring to in the database not on the screen?

mlmcc
0
 
bhagyeshtCommented:
just check for access table properties for the field/s you are editing and check if your value matches with the constraints?
0
 
matt_fennellAuthor Commented:
Ok, I sorted out the problem on one screen, where my username was a particularly long one and was not accepted in Access as I set the constraint to 15 characters. I will look into what I can do for the check box. Thanks
0
 
mlmccCommented:
What check box?

mlmcc
0
 
matt_fennellAuthor Commented:
I had a similar problem when clicking an unclicking a text box, but I simply just refreshed the data instead of trying to edit it and then update.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now