code issue

D

dchristo

I am having a problem with this code:

This is in pop up combo box - once someone selects the item(s) and closes
the box - the record that was to be populated with the selection gets messed
up.

Do you see anything that could be causing the problem?

Private Sub Dmglist_AfterUpdate()
Dim varvalue As Variant
Dim strDmglist As String
Dim strSQL As String
For Each varvalue In Me.Dmglist.ItemsSelected

strDmglist = strDmglist & Me!Dmglist.Column(0, varvalue) & ", "

Next varvalue

strDmglist = Left$(strDmglist, Len(strDmglist) - 2)

strSQL = "UPDATE [form] SET [form].[property] = '" & strDmglist & "'where
[ln#]=" & Me!Text5

DoCmd.SetWarnings False
DoCmd.RunSQL (strSQL)
DoCmd.SetWarnings True

End Sub
 
B

Barry Gilbert

What do you mean by "messed up"? One of the problems with Docmd.RunSql is
that you won't get back any error messages from the database. You should
consider using CurrentDb.Execute and using dbFailOnError.

Barry
 
D

dchristo

The all fields in the record become gibberish ex. the acct no field becomes
-4.03963231855502E+90 when it should be 4587965, the date fields become
12/31/1899 or 12:00:00 AM
Barry Gilbert said:
What do you mean by "messed up"? One of the problems with Docmd.RunSql is
that you won't get back any error messages from the database. You should
consider using CurrentDb.Execute and using dbFailOnError.

Barry

dchristo said:
I am having a problem with this code:

This is in pop up combo box - once someone selects the item(s) and closes
the box - the record that was to be populated with the selection gets messed
up.

Do you see anything that could be causing the problem?

Private Sub Dmglist_AfterUpdate()
Dim varvalue As Variant
Dim strDmglist As String
Dim strSQL As String
For Each varvalue In Me.Dmglist.ItemsSelected

strDmglist = strDmglist & Me!Dmglist.Column(0, varvalue) & ", "

Next varvalue

strDmglist = Left$(strDmglist, Len(strDmglist) - 2)

strSQL = "UPDATE [form] SET [form].[property] = '" & strDmglist & "'where
[ln#]=" & Me!Text5

DoCmd.SetWarnings False
DoCmd.RunSQL (strSQL)
DoCmd.SetWarnings True

End Sub
 
B

Barry Gilbert

Do I interpret your code correctly? It looks like you have a table called
[Form] and a column called [Property]. You're updating this column with all
the values selected in a combobox, seperated by commas. You also seem to be
saying that when you do this update, other columns in the same record are
changing. Is that right?

dchristo said:
The all fields in the record become gibberish ex. the acct no field becomes
-4.03963231855502E+90 when it should be 4587965, the date fields become
12/31/1899 or 12:00:00 AM
Barry Gilbert said:
What do you mean by "messed up"? One of the problems with Docmd.RunSql is
that you won't get back any error messages from the database. You should
consider using CurrentDb.Execute and using dbFailOnError.

Barry

dchristo said:
I am having a problem with this code:

This is in pop up combo box - once someone selects the item(s) and closes
the box - the record that was to be populated with the selection gets messed
up.

Do you see anything that could be causing the problem?

Private Sub Dmglist_AfterUpdate()
Dim varvalue As Variant
Dim strDmglist As String
Dim strSQL As String
For Each varvalue In Me.Dmglist.ItemsSelected

strDmglist = strDmglist & Me!Dmglist.Column(0, varvalue) & ", "

Next varvalue

strDmglist = Left$(strDmglist, Len(strDmglist) - 2)

strSQL = "UPDATE [form] SET [form].[property] = '" & strDmglist & "'where
[ln#]=" & Me!Text5

DoCmd.SetWarnings False
DoCmd.RunSQL (strSQL)
DoCmd.SetWarnings True

End Sub
 
D

dchristo

Form is the actual form, property is a field in the record

but yes, that is exactly what is happening

Barry Gilbert said:
Do I interpret your code correctly? It looks like you have a table called
[Form] and a column called [Property]. You're updating this column with all
the values selected in a combobox, seperated by commas. You also seem to be
saying that when you do this update, other columns in the same record are
changing. Is that right?

dchristo said:
The all fields in the record become gibberish ex. the acct no field becomes
-4.03963231855502E+90 when it should be 4587965, the date fields become
12/31/1899 or 12:00:00 AM
Barry Gilbert said:
What do you mean by "messed up"? One of the problems with Docmd.RunSql is
that you won't get back any error messages from the database. You should
consider using CurrentDb.Execute and using dbFailOnError.

Barry

:

I am having a problem with this code:

This is in pop up combo box - once someone selects the item(s) and closes
the box - the record that was to be populated with the selection gets messed
up.

Do you see anything that could be causing the problem?

Private Sub Dmglist_AfterUpdate()
Dim varvalue As Variant
Dim strDmglist As String
Dim strSQL As String
For Each varvalue In Me.Dmglist.ItemsSelected

strDmglist = strDmglist & Me!Dmglist.Column(0, varvalue) & ", "

Next varvalue

strDmglist = Left$(strDmglist, Len(strDmglist) - 2)

strSQL = "UPDATE [form] SET [form].[property] = '" & strDmglist & "'where
[ln#]=" & Me!Text5

DoCmd.SetWarnings False
DoCmd.RunSQL (strSQL)
DoCmd.SetWarnings True

End Sub
 
D

dchristo

Sorry Form is the name of the table

Barry Gilbert said:
Do I interpret your code correctly? It looks like you have a table called
[Form] and a column called [Property]. You're updating this column with all
the values selected in a combobox, seperated by commas. You also seem to be
saying that when you do this update, other columns in the same record are
changing. Is that right?

dchristo said:
The all fields in the record become gibberish ex. the acct no field becomes
-4.03963231855502E+90 when it should be 4587965, the date fields become
12/31/1899 or 12:00:00 AM
Barry Gilbert said:
What do you mean by "messed up"? One of the problems with Docmd.RunSql is
that you won't get back any error messages from the database. You should
consider using CurrentDb.Execute and using dbFailOnError.

Barry

:

I am having a problem with this code:

This is in pop up combo box - once someone selects the item(s) and closes
the box - the record that was to be populated with the selection gets messed
up.

Do you see anything that could be causing the problem?

Private Sub Dmglist_AfterUpdate()
Dim varvalue As Variant
Dim strDmglist As String
Dim strSQL As String
For Each varvalue In Me.Dmglist.ItemsSelected

strDmglist = strDmglist & Me!Dmglist.Column(0, varvalue) & ", "

Next varvalue

strDmglist = Left$(strDmglist, Len(strDmglist) - 2)

strSQL = "UPDATE [form] SET [form].[property] = '" & strDmglist & "'where
[ln#]=" & Me!Text5

DoCmd.SetWarnings False
DoCmd.RunSQL (strSQL)
DoCmd.SetWarnings True

End Sub
 
B

Barry Gilbert

It probably shouldn't do that. Is the property field large enough to handle
what you're pasting? If you manually paste the string into the field, does it
take it?

dchristo said:
Form is the actual form, property is a field in the record

but yes, that is exactly what is happening

Barry Gilbert said:
Do I interpret your code correctly? It looks like you have a table called
[Form] and a column called [Property]. You're updating this column with all
the values selected in a combobox, seperated by commas. You also seem to be
saying that when you do this update, other columns in the same record are
changing. Is that right?

dchristo said:
The all fields in the record become gibberish ex. the acct no field becomes
-4.03963231855502E+90 when it should be 4587965, the date fields become
12/31/1899 or 12:00:00 AM
:

What do you mean by "messed up"? One of the problems with Docmd.RunSql is
that you won't get back any error messages from the database. You should
consider using CurrentDb.Execute and using dbFailOnError.

Barry

:

I am having a problem with this code:

This is in pop up combo box - once someone selects the item(s) and closes
the box - the record that was to be populated with the selection gets messed
up.

Do you see anything that could be causing the problem?

Private Sub Dmglist_AfterUpdate()
Dim varvalue As Variant
Dim strDmglist As String
Dim strSQL As String
For Each varvalue In Me.Dmglist.ItemsSelected

strDmglist = strDmglist & Me!Dmglist.Column(0, varvalue) & ", "

Next varvalue

strDmglist = Left$(strDmglist, Len(strDmglist) - 2)

strSQL = "UPDATE [form] SET [form].[property] = '" & strDmglist & "'where
[ln#]=" & Me!Text5

DoCmd.SetWarnings False
DoCmd.RunSQL (strSQL)
DoCmd.SetWarnings True

End Sub
 
D

dchristo

I thought that too, so I changed from a text field to a memo field. It does
not happen all the time only maybe 5 to 6 times a week, but the record is
ruined and it cannot be fixed. The users are not very happy, and of course,
when I try to recreate the problem it does not happen.

Do you have any suggestions?

Barry Gilbert said:
It probably shouldn't do that. Is the property field large enough to handle
what you're pasting? If you manually paste the string into the field, does it
take it?

dchristo said:
Form is the actual form, property is a field in the record

but yes, that is exactly what is happening

Barry Gilbert said:
Do I interpret your code correctly? It looks like you have a table called
[Form] and a column called [Property]. You're updating this column with all
the values selected in a combobox, seperated by commas. You also seem to be
saying that when you do this update, other columns in the same record are
changing. Is that right?

:

The all fields in the record become gibberish ex. the acct no field becomes
-4.03963231855502E+90 when it should be 4587965, the date fields become
12/31/1899 or 12:00:00 AM
:

What do you mean by "messed up"? One of the problems with Docmd.RunSql is
that you won't get back any error messages from the database. You should
consider using CurrentDb.Execute and using dbFailOnError.

Barry

:

I am having a problem with this code:

This is in pop up combo box - once someone selects the item(s) and closes
the box - the record that was to be populated with the selection gets messed
up.

Do you see anything that could be causing the problem?

Private Sub Dmglist_AfterUpdate()
Dim varvalue As Variant
Dim strDmglist As String
Dim strSQL As String
For Each varvalue In Me.Dmglist.ItemsSelected

strDmglist = strDmglist & Me!Dmglist.Column(0, varvalue) & ", "

Next varvalue

strDmglist = Left$(strDmglist, Len(strDmglist) - 2)

strSQL = "UPDATE [form] SET [form].[property] = '" & strDmglist & "'where
[ln#]=" & Me!Text5

DoCmd.SetWarnings False
DoCmd.RunSQL (strSQL)
DoCmd.SetWarnings True

End Sub
 
B

Barry Gilbert

This one's beyond me. Sorry.

dchristo said:
I thought that too, so I changed from a text field to a memo field. It does
not happen all the time only maybe 5 to 6 times a week, but the record is
ruined and it cannot be fixed. The users are not very happy, and of course,
when I try to recreate the problem it does not happen.

Do you have any suggestions?

Barry Gilbert said:
It probably shouldn't do that. Is the property field large enough to handle
what you're pasting? If you manually paste the string into the field, does it
take it?

dchristo said:
Form is the actual form, property is a field in the record

but yes, that is exactly what is happening

:

Do I interpret your code correctly? It looks like you have a table called
[Form] and a column called [Property]. You're updating this column with all
the values selected in a combobox, seperated by commas. You also seem to be
saying that when you do this update, other columns in the same record are
changing. Is that right?

:

The all fields in the record become gibberish ex. the acct no field becomes
-4.03963231855502E+90 when it should be 4587965, the date fields become
12/31/1899 or 12:00:00 AM
:

What do you mean by "messed up"? One of the problems with Docmd.RunSql is
that you won't get back any error messages from the database. You should
consider using CurrentDb.Execute and using dbFailOnError.

Barry

:

I am having a problem with this code:

This is in pop up combo box - once someone selects the item(s) and closes
the box - the record that was to be populated with the selection gets messed
up.

Do you see anything that could be causing the problem?

Private Sub Dmglist_AfterUpdate()
Dim varvalue As Variant
Dim strDmglist As String
Dim strSQL As String
For Each varvalue In Me.Dmglist.ItemsSelected

strDmglist = strDmglist & Me!Dmglist.Column(0, varvalue) & ", "

Next varvalue

strDmglist = Left$(strDmglist, Len(strDmglist) - 2)

strSQL = "UPDATE [form] SET [form].[property] = '" & strDmglist & "'where
[ln#]=" & Me!Text5

DoCmd.SetWarnings False
DoCmd.RunSQL (strSQL)
DoCmd.SetWarnings True

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top