Results 1 to 18 of 18

Thread: Help...

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2004
    Posts
    344

    Help...

    I have this code :

    VB Code:
    1. Sub UpdateMe()
    2.     With frmMain.ContactTable
    3.         .MoveFirst
    4.         Do While Not .EOF
    5.             If !LName & ", " & !Fname = Tag Then
    6.                 Exit Do
    7.             Else
    8.                 .MoveNext
    9.             End If
    10.         Loop
    11.         On Error Resume Next
    12.         .Edit
    13.         If txtFName <> "" Then !Fname = txtFName
    14.         If txtLName <> "" Then !LName = txtLName
    15.         If txtPhone <> "" Then !Phone = txtPhone
    16.         If txtAdd <> "" Then !Address1 = txtAdd
    17.         If txtZip <> "" Then !Zip = txtZip
    18.         If txtNotes <> "" Then !Notes = txtNotes
    19.         If txtEmail <> "" Then !EMail = txtEmail
    20.         If txtInfo <> "" Then !Info = txtInfo      '<--- I added this
    21.         If txtPic <> "" Then
    22.             !pic = txtPic
    23.         Else
    24.             !pic = " "
    25.         End If
    26.         If cmbCat.ListIndex > -1 Then !Cat = cmbCat.ListIndex
    27.         If cmbBDayM.ListIndex > -1 Then !BDayM = Left(cmbBDayM.Text, 2)
    28.         If cmbBDayD.ListIndex > -1 Then !BDayD = cmbBDayD.ListIndex + 1
    29.         If cmbBDayY.ListIndex > -1 Then !BDayY = cmbBDayY.Text
    30.         .Update
    31.     End With
    32.     frmContList.LoadContacts
    33.     Changes = False
    34. End Sub

    The problem Im facing is that when I add a new text box (txtInfo) in my form for the user to key in text, the text is updated in the database but it is not shown in the form. Is there anything wrong with this code? Please advice...


  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,123

    Re: Help...

    What's in your...

    VB Code:
    1. frmContList.LoadContacts
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2004
    Posts
    344

    Re: Help...

    Quote Originally Posted by dee-u
    What's in your...

    VB Code:
    1. frmContList.LoadContacts
    VB Code:
    1. Sub LoadContacts()
    2.     List1.Clear
    3.     With frmMain.ContactTable
    4.         If .RecordCount = 0 Then Exit Sub
    5.         .MoveFirst
    6.         Do While Not .EOF
    7.             List1.AddItem !LName & ", " & !Fname
    8.             .MoveNext
    9.         Loop
    10.     End With
    11. End Sub


  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Help...

    Take the On Error Resume Next out, run it, and see if you are perhaps getting an error there that is being ignored.

  5. #5
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    Re: Help...

    Did you add the actual text box to the form, or did you just add the code? (Not having Option Explicit would keep you from seeing this.)

  6. #6
    Addicted Member BlueRose's Avatar
    Join Date
    Jan 2002
    Location
    ISTANBUL
    Posts
    245

    Re: Help...

    How can you write values into a form? colud you show your code doing this?
    You can do while you think that you can do

    If you think my answer solve your question, please rate it.

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2004
    Posts
    344

    Re: Help...

    Quote Originally Posted by Al42
    Did you add the actual text box to the form, or did you just add the code? (Not having Option Explicit would keep you from seeing this.)
    I have add a text box to the form. It is not displaying anything, but when I open up the database, the data is already written in the database, just that is is not shown in the text box.

  8. #8
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: Help...

    i couldnt see any code to clear the contents of your text box....atleast from the codings you have posted...
    did you follow Hack's post...
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2004
    Posts
    344

    Re: Help...

    Quote Originally Posted by ganeshmoorthy
    i couldnt see any code to clear the contents of your text box....atleast from the codings you have posted...
    did you follow Hack's post...
    Sorry, I tried Hack's advice but still getting the same result.

    VB Code:
    1. Public Changes As Boolean
    2.  
    3. Private Sub txtInfo_change()
    4.     Changes = True
    5. End Sub
    6.  
    7. Sub UpdateMe()
    8.     With frmMain.ContactTable
    9.         .MoveFirst
    10.         Do While Not .EOF
    11.             If !LName & ", " & !Fname = Tag Then
    12.                 Exit Do
    13.             Else
    14.                 .MoveNext
    15.             End If
    16.         Loop
    17.        
    18.         .Edit
    19.         If txtFName <> "" Then !Fname = txtFName
    20.         If txtLName <> "" Then !LName = txtLName
    21.         If txtPhone <> "" Then !Phone = txtPhone
    22.         If txtAdd <> "" Then !Address1 = txtAdd
    23.         If txtZip <> "" Then !Zip = txtZip
    24.         If txtNotes <> "" Then !Notes = txtNotes
    25.         If txtEmail <> "" Then !EMail = txtEmail
    26.         If txtInfo <> "" Then !Info = txtInfo      '<--- I added this
    27.         If txtPic <> "" Then
    28.             !pic = txtPic
    29.         Else
    30.             !pic = " "
    31.         End If
    32.         If cmbCat.ListIndex > -1 Then !Cat = cmbCat.ListIndex
    33.         If cmbBDayM.ListIndex > -1 Then !BDayM = Left(cmbBDayM.Text, 2)
    34.         If cmbBDayD.ListIndex > -1 Then !BDayD = cmbBDayD.ListIndex + 1
    35.         If cmbBDayY.ListIndex > -1 Then !BDayY = cmbBDayY.Text
    36.         .Update
    37.     End With
    38.     frmContList.LoadContacts
    39.     Changes = False
    40.  
    41. End Sub

    Please advice...

  10. #10
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: Help...

    what is the error you are getting now...if no error then comment this
    VB Code:
    1. If txtInfo <> "" Then !Info = txtInfo      '<--- I added this
    and try,
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  11. #11
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: Help...

    hey what do you do with this
    VB Code:
    1. Private Sub txtInfo_change()
    2.     Changes = True
    3. End Sub
    remove this and the below also in your UpdateMe code
    VB Code:
    1. Changes = False
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  12. #12

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2004
    Posts
    344

    Re: Help...

    Quote Originally Posted by ganeshmoorthy
    what is the error you are getting now...if no error then comment this
    VB Code:
    1. If txtInfo <> "" Then !Info = txtInfo      '<--- I added this
    and try,
    Im not getting any error, and I have comment this:

    VB Code:
    1. If txtInfo <> "" Then !Info = txtInfo      '<--- I added this

    Still after I click update and reopen the form, nothing display in the txtinfo box.

  13. #13
    Hyperactive Member
    Join Date
    May 2005
    Posts
    307

    Re: Help...

    whats the code to open the form....maybe something there isnt right

  14. #14

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2004
    Posts
    344

    Re: Help...

    I have this update button in my form, so when there is a changes, it will update when click.
    VB Code:
    1. Private Sub Command1_Click()
    2.     If Changes = True Then UpdateMe: MsgBox "Updated!", vbExclamation, "Updated"
    3. End Sub


  15. #15

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2004
    Posts
    344

    Re: Help...

    Quote Originally Posted by whythetorment
    whats the code to open the form....maybe something there isnt right
    These are the codes when the form loads :

    VB Code:
    1. Private Sub Form_Load()
    2.     FillDates
    3. End Sub
    4.  
    5. Sub FillDates()
    6.   Dim X As Integer
    7.   Dim TempDate As Date
    8.     For X = 1 To 12
    9.         TempDate = Format(X, "00") & "/01/00"
    10.         cmbBDayM.AddItem Format(X, "00") & "- " & Format(TempDate, "mmm")
    11.     Next X
    12.     For X = 1 To 31
    13.         cmbBDayD.AddItem Format(X, "00")
    14.     Next X
    15.    
    16.     For X = 1940 To Year(Date)
    17.         cmbBDayY.AddItem X
    18.     Next X
    19.    
    20. End Sub


  16. #16
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: Help...

    do one thing...search your form's coding with this
    VB Code:
    1. txtInfo =
    and check if you are assigning any data or "" to it anywhere...
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  17. #17

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2004
    Posts
    344

    Re: Help...

    Quote Originally Posted by ganeshmoorthy
    do one thing...search your form's coding with this
    VB Code:
    1. txtInfo =
    and check if you are assigning any data or "" to it anywhere...
    Done with the search, but did not find any txtinfo assigned.

  18. #18
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,123

    Re: Help...

    Just want to ask you a few questions... Are your textbox databound? And is ContactTable a data control?

    If you answer yes on the above question then I would guess your problem is in your...

    VB Code:
    1. Sub LoadContacts()
    2.     List1.Clear
    3.     With frmMain.ContactTable
    4.         If .RecordCount = 0 Then Exit Sub
    5.         .MoveFirst
    6.         Do While Not .EOF
    7.             List1.AddItem !LName & ", " & !Fname
    8.             .MoveNext
    9.         Loop
    10.     End With
    11. End Sub

    After adding a new record you are calling your above procedure which moves to different record, what I would suggest is you a refresh before looping, after your looping you would have to find that record you have added/edited...
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

Posting Permissions

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



Click Here to Expand Forum to Full Width