-
Apr 10th, 2006, 02:41 AM
#1
Thread Starter
Hyperactive Member
Help...
I have this code :
VB Code:
Sub UpdateMe()
With frmMain.ContactTable
.MoveFirst
Do While Not .EOF
If !LName & ", " & !Fname = Tag Then
Exit Do
Else
.MoveNext
End If
Loop
On Error Resume Next
.Edit
If txtFName <> "" Then !Fname = txtFName
If txtLName <> "" Then !LName = txtLName
If txtPhone <> "" Then !Phone = txtPhone
If txtAdd <> "" Then !Address1 = txtAdd
If txtZip <> "" Then !Zip = txtZip
If txtNotes <> "" Then !Notes = txtNotes
If txtEmail <> "" Then !EMail = txtEmail
If txtInfo <> "" Then !Info = txtInfo '<--- I added this
If txtPic <> "" Then
!pic = txtPic
Else
!pic = " "
End If
If cmbCat.ListIndex > -1 Then !Cat = cmbCat.ListIndex
If cmbBDayM.ListIndex > -1 Then !BDayM = Left(cmbBDayM.Text, 2)
If cmbBDayD.ListIndex > -1 Then !BDayD = cmbBDayD.ListIndex + 1
If cmbBDayY.ListIndex > -1 Then !BDayY = cmbBDayY.Text
.Update
End With
frmContList.LoadContacts
Changes = False
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...
-
Apr 10th, 2006, 03:26 AM
#2
-
Apr 10th, 2006, 04:09 AM
#3
Thread Starter
Hyperactive Member
Re: Help...
Originally Posted by dee-u
VB Code:
Sub LoadContacts()
List1.Clear
With frmMain.ContactTable
If .RecordCount = 0 Then Exit Sub
.MoveFirst
Do While Not .EOF
List1.AddItem !LName & ", " & !Fname
.MoveNext
Loop
End With
End Sub
-
Apr 10th, 2006, 07:47 AM
#4
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.
-
Apr 10th, 2006, 09:52 AM
#5
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.)
-
Apr 10th, 2006, 02:16 PM
#6
Addicted Member
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.
-
Apr 11th, 2006, 03:36 AM
#7
Thread Starter
Hyperactive Member
Re: Help...
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.
-
Apr 11th, 2006, 03:47 AM
#8
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.
-
Apr 11th, 2006, 03:56 AM
#9
Thread Starter
Hyperactive Member
Re: Help...
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:
Public Changes As Boolean
Private Sub txtInfo_change()
Changes = True
End Sub
Sub UpdateMe()
With frmMain.ContactTable
.MoveFirst
Do While Not .EOF
If !LName & ", " & !Fname = Tag Then
Exit Do
Else
.MoveNext
End If
Loop
.Edit
If txtFName <> "" Then !Fname = txtFName
If txtLName <> "" Then !LName = txtLName
If txtPhone <> "" Then !Phone = txtPhone
If txtAdd <> "" Then !Address1 = txtAdd
If txtZip <> "" Then !Zip = txtZip
If txtNotes <> "" Then !Notes = txtNotes
If txtEmail <> "" Then !EMail = txtEmail
If txtInfo <> "" Then !Info = txtInfo '<--- I added this
If txtPic <> "" Then
!pic = txtPic
Else
!pic = " "
End If
If cmbCat.ListIndex > -1 Then !Cat = cmbCat.ListIndex
If cmbBDayM.ListIndex > -1 Then !BDayM = Left(cmbBDayM.Text, 2)
If cmbBDayD.ListIndex > -1 Then !BDayD = cmbBDayD.ListIndex + 1
If cmbBDayY.ListIndex > -1 Then !BDayY = cmbBDayY.Text
.Update
End With
frmContList.LoadContacts
Changes = False
End Sub
Please advice...
-
Apr 11th, 2006, 04:02 AM
#10
Re: Help...
what is the error you are getting now...if no error then comment this
VB Code:
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.
-
Apr 11th, 2006, 04:04 AM
#11
Re: Help...
hey what do you do with this
VB Code:
Private Sub txtInfo_change()
Changes = True
End Sub
remove this and the below also in your UpdateMe code
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.
-
Apr 11th, 2006, 04:09 AM
#12
Thread Starter
Hyperactive Member
Re: Help...
Originally Posted by ganeshmoorthy
what is the error you are getting now...if no error then comment this
VB Code:
If txtInfo <> "" Then !Info = txtInfo '<--- I added this
and try,
Im not getting any error, and I have comment this:
VB Code:
If txtInfo <> "" Then !Info = txtInfo '<--- I added this
Still after I click update and reopen the form, nothing display in the txtinfo box.
-
Apr 11th, 2006, 04:13 AM
#13
Hyperactive Member
Re: Help...
whats the code to open the form....maybe something there isnt right
-
Apr 11th, 2006, 04:14 AM
#14
Thread Starter
Hyperactive Member
Re: Help...
I have this update button in my form, so when there is a changes, it will update when click.
VB Code:
Private Sub Command1_Click()
If Changes = True Then UpdateMe: MsgBox "Updated!", vbExclamation, "Updated"
End Sub
-
Apr 11th, 2006, 04:17 AM
#15
Thread Starter
Hyperactive Member
Re: Help...
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:
Private Sub Form_Load()
FillDates
End Sub
Sub FillDates()
Dim X As Integer
Dim TempDate As Date
For X = 1 To 12
TempDate = Format(X, "00") & "/01/00"
cmbBDayM.AddItem Format(X, "00") & "- " & Format(TempDate, "mmm")
Next X
For X = 1 To 31
cmbBDayD.AddItem Format(X, "00")
Next X
For X = 1940 To Year(Date)
cmbBDayY.AddItem X
Next X
End Sub
-
Apr 11th, 2006, 04:17 AM
#16
Re: Help...
do one thing...search your form's coding with this
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.
-
Apr 11th, 2006, 04:21 AM
#17
Thread Starter
Hyperactive Member
Re: Help...
Originally Posted by ganeshmoorthy
do one thing...search your form's coding with this
and check if you are assigning any data or "" to it anywhere...
Done with the search, but did not find any txtinfo assigned.
-
Apr 11th, 2006, 04:26 AM
#18
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:
Sub LoadContacts()
List1.Clear
With frmMain.ContactTable
If .RecordCount = 0 Then Exit Sub
.MoveFirst
Do While Not .EOF
List1.AddItem !LName & ", " & !Fname
.MoveNext
Loop
End With
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...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|