Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to delete mulitple feilds in a record? 1

Status
Not open for further replies.

number2

Technical User
Oct 25, 2001
284
US
I need to allow the user to delete a series of seven feilds within the record. How can this be acheived?
 
Attach this code to an event on your form. Note- change the blue to match the names in your db. I only included 2 fields in the example. If you can not get it to work please provide more info on datatypes and indexes...

CurrentDb.Execute ("UPDATE TableName SET FieldName1 = Null, FieldName2 = Null WHERE textFieldName '" & Me.textControlName & "'")
 
Thanks this will help a great deal, I am however having difficulty identifying the specific names of the "textFieldName" and the "textControlName". What part of the form/table are these?
 
textControlName is the name of the control on the form and textFieldName is the name of the field that control is bound to. Note- the example I provided will only work for one field if your table is using more than one field as a key you will need to change the code. So if you have a table like so...

textFieldName intFieldName
data1 1
data2 2

Then you'll be ok. But if your table is like so...

textFieldName textFieldName1 intFieldName
data1 data1 1
data1 data2 2

Then you'd want some different code. Let me know.
 
Thanks so much for working me through this one. I will try to work it out and let you know how it goes. I need to have this working by tomarrow so..thanks!
 
I still can not identify the "textFieldName" and the "textControlName" names. Arn't I already using the FeildName in the first part of the code?
 

Hi,

butting in...

There is a "field name", and there is a "control name".
You may have a field named, "MyFieldOne". When you drag the text box control to the design view of the form, Access will assign it a "control name", like "text1" or something close. This is not the same thing as a "field name".

You can rename the control name (e.g., "txtMyFieldOne" in Properties>Other. I have a lot of controls with the generic name provided by Access. I also have some controls with names identical to the field names they represent...this is supposed to be troublesome, I'm not sure why...

With apologies to Pezamystik, I am
Gus Brunston :cool: An old PICKer, using Access2000
padregus@attbi.com

 
Well I am lost here. I have no idea how to gleen the required names out of all this. Does anyone have any suggestions?
I have to clear the feilds with the following name characteristics:

Control source: comdate1 (to 7)
Feild name: (properties other name) comdate1 (to7)
Table name: QMEinfo

I apparently require an additional name?

I also need to clear 2 other fields, also in a series of 1-7.
 
I really couldn't have explained it any better than Gus. Here is the code.

CurrentDb.Execute ("UPDATE QMEinfo SET comdate1= Null, comdate2 = Null, comdate3 = Null, comdate4 = Null, comdate5 = Null, comdate6 = Null, comdate7 = Null WHERE comdate1=" & "#" & Me.comdate1 & "#" & " and comdate2=" & "#" & Me.comdate2 & "#" & " and comdate3=" & "#" & Me.comdate3 & "#" & " and comdate4=" & "#" & Me.comdate4 & "#" & " and comdate5=" & "#" & Me.comdate5 & "#" & " and comdate6=" & "#" & Me.comdate6 & "#" & " and comdate7=" & "#" & Me.comdate7 & "#"
 
Sorry for my slow take on this. I run this and get a syntax error which I can not find.
 
Try this...
CurrentDb.Execute ("UPDATE QMEinfo SET comdate1= Null, comdate2 = Null, comdate3 = Null, comdate4 = Null, comdate5 = Null, comdate6 = Null, comdate7 = Null WHERE comdate1=" & Me.comdate1 & " and comdate2=" & Me.comdate2 & " and comdate3=" & Me.comdate3 & " and comdate4=" & Me.comdate4 & " and comdate5=" & Me.comdate5 & " and comdate6=" & Me.comdate6 & " and comdate7=" & Me.comdate7)
 
I get a syntax error still. I thnk the problem lies with the fact that I am using a date time picker to fill the feild. It is returning a full date and full time. The error is a missing operator error.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top