Consulting

Results 1 to 7 of 7

Thread: Solved: User Form/ Database Problems

  1. #1
    VBAX Regular
    Joined
    Jul 2006
    Location
    Kentucky
    Posts
    10
    Location

    Solved: User Form/ Database Problems

    Hi. I have just started learning VBA and am fascinated with it, but I have found very little information that can help me understand it better. Currently I am working on a spreadsheet and have a an issue with how to program it. The userform works but when I enter the information into the base it will not allow me to add a new row of data. It only deletes what i had and stores what is in the user form in the same row. Is there a simple solution to this? I have a reference book and tried using the code like it stated but it keeps giving me a sytax error. Any help will be very much appreciated.
    Thanks

    Here is the way my code looks, I am new to this so any help would be great.I dont really understand about variable or intergers yet but I am learning

    [VBA]
    Private Sub tbenter1_Click()

    Dim x As Range
    Dim j As XlRowCol
    Dim inextrow As Integer

    Set x = Sheet2.Rows(3)
    j = xlRows


    With x
    .Cells(j, 1) = uf1.tblname1.Value
    End With

    If uf1.tblname1.TextLength = 0 Then
    MsgBox "Please Enter a Last Name", _
    vbExclamation, "Warning !!"
    Exit Sub
    End If

    With x
    .Cells(j, 2) = uf1.tbfname1.Value
    End With

    If uf1.tbfname1.TextLength = 0 Then
    MsgBox "Please Enter a First Name", _
    vbExclamation, "Warning !!"
    Exit Sub
    End If
    With x
    .Cells(j, 3) = uf1.tbadd1.Value
    End With

    If uf1.tbadd1.TextLength = 0 Then
    MsgBox "Please Enter an Address", _
    vbExclamation, "Warning !!"
    Exit Sub
    End If
    With x
    .Cells(j, 4) = uf1.tbcity1.Value
    End With

    If uf1.tbcity1.TextLength = 0 Then
    MsgBox "Please Enter a City", _
    vbExclamation, "Warning !!"
    Exit Sub
    End If

    With x
    .Cells(j, 5) = uf1.tbstate1.Value
    End With

    If uf1.tbstate1.TextLength = 0 Then
    MsgBox "Please Enter a State", _
    vbExclamation, "Warning !!"
    Exit Sub
    End If


    With x
    .Cells(j, 6) = uf1.tbzip1.Value
    End With

    If uf1.tbzip1.TextLength = 0 Then
    MsgBox "Please Enter a Zip Code", _
    vbExclamation, "Warning !!"
    Exit Sub
    End If

    With x
    .Cells(j, 7) = uf1.tbhome1.Value
    End With

    If uf1.tbhome1.TextLength = 0 Then
    MsgBox "Please Enter a Telephone Number", _
    vbExclamation, "Warning !!"
    Exit Sub
    End If

    With x
    .Cells(j, 8) = uf1.tbcell1.Value
    End With







    Unload uf1
    Workbooks.Application.GetSaveAsFilename
    End Sub
    [/VBA]
    Steve, please select your code and hit the vba button when posting. I have edited your code in this way, it makes it easier to read. Lucas
    Last edited by Steve41031; 07-27-2006 at 07:47 PM.

  2. #2
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Hi Steve,
    It would really help if you could post a sanitized version of your workbook with any sensitive data removed. It would save responders from having to reproduce your userform, etc. Your problem sounds pretty easy if we could see it I'm sure we could "Git er done".....
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  3. #3
    VBAX Regular
    Joined
    Jul 2006
    Location
    Kentucky
    Posts
    10
    Location
    My workbook is fairly quite simple. The userform contains 8 text boxes: last name, first name, address, city, state, zip, phone and cell. it has three command buttons, enter, search and cancel. It has two sheets for data. I hope this helps you bellter understand it. Thanks

  4. #4
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Too much char this evening so here is an example along the lines you have mentioned.....should fill in some blanks for you.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  5. #5
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    I just noticed your a new member of the forum...welcome to vbaexpress!
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  6. #6
    VBAX Regular
    Joined
    Jul 2006
    Location
    Kentucky
    Posts
    10
    Location
    Here is my workbook...........I think what you had worked great........I will try to apply it to mine.
    Thank You very much !!!

  7. #7
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Glad to help Steve, if you have problems be sure to post back here and someone will point you in the right direction.

    ps I worked a union job at Ashland a couple of years back....union electrician?
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •