473,714 Members | 2,580 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Form For Edit & Delete

mseo
181 New Member
hi,
I have form for edit and delete
within me form edit or delete job
I have before_update trigger
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_beforeUpdate(Cancel As Integer)
  2.     If IsNull(Me![JobTitle]) Then
  3.         MsgBox "You must enter a Job first then you can save it", vbExclamation
  4.         Cancel = True: Me![JobTitle].SetFocus
  5.     ElseIf IsNull(Me![Job_ID]) Then
  6.         MsgBox "You must enter The ID then you can save it", vbExclamation
  7.         Cancel = True: Me![Job_ID].SetFocus
  8.     End If
  9. End Sub
If I left or removed the textbox Job_id
and clicked save it works great and the same for delete
but if select the value for combobox to research and the value of job_id is null in the viewed record i get error
number 3021 (no current record)
the code on search button
Expand|Select|Wrap|Line Numbers
  1. Private Sub Search_Click()
  2.     Dim strjobRef As String
  3.     Dim strSearch As String
  4.     If IsNull(Me![cboJob_ID]) Or (Me![cboJob_ID]) = "" Then
  5.         MsgBox "Please enter or Select a Job!", vbOKOnly, "Invalid Search Criterion!"
  6.         Me![cboJob_ID].SetFocus
  7.     Exit Sub
  8. End If
  9.     DoCmd.ShowAllRecords
  10.     DoCmd.GoToControl ("job_ID")
  11.     DoCmd.FindRecord Me!cboJob_ID
  12.    Job_ID.SetFocus
  13.     strjobRef = Job_ID.Text
  14.     cboJob_ID.SetFocus
  15.     strSearch = cboJob_ID.Text
  16.     If strjobRef = strSearch Then
  17.         MsgBox "Match Found For: " & strSearch, , "Congratulations!"
  18.         Job_ID.SetFocus
  19.         cboJob_ID = ""
  20.         Else
  21.           MsgBox "Match Not Found For: " & strSearch & " - Please Try Again.", _
  22.             , "Invalid Search Criterion!"
  23.             cboJob_ID.SetFocus
  24.  
  25.     End If
  26. End Sub
  27.  
the error stems from this line:
Expand|Select|Wrap|Line Numbers
  1. docmd.showallrecords
any help would be appreciated
thank you very much
Jun 26 '10 #1
11 2132
mseo
181 New Member
hi,
I need a solution for this problem
thank you
Jul 8 '10 #2
patjones
931 Recognized Expert Contributor
What happens when you remove DoCmd.ShowAllRe cords? I have never used this before, but based on a quick review it seems like you shouldn't need it unless there was a filter previously applied to the form's recordsource.

Pat
Jul 8 '10 #3
mseo
181 New Member
@zepphead80
thank you for your reply
when I remove DoCmd.ShowAllRe cords I get error for next lines of code
DoCmd.GoToContr ol ("job_ID")
DoCmd.FindRecor d Me!cboJob_ID
I think the code I use doesn't work perfectly for the purpose of edit form
so I would use create predicate , with beforeupdate trigger to prevent controls to be null
please provide me any suggestions
thank you I really appreciate your help
Jul 8 '10 #4
patjones
931 Recognized Expert Contributor
Is this a bound form, and if so where are you setting the form's recordsource?
Jul 8 '10 #5
mseo
181 New Member
I use bound controls form and tbl_jobs record source
because i am not familiar with using unbound forms
but if the form work properly with unbound controls form I will try it
thank you very much
Jul 8 '10 #6
mseo
181 New Member
thank you very much
I can use create predicate code to find the record and it works fine, for edit's forms and doesn't collide with before_update trigger but i still need why the above-mentioned code generates this error, just for knowing
thank you
Jul 9 '10 #7
patjones
931 Recognized Expert Contributor
@mseo
What is the error that you're getting?
Jul 12 '10 #8
mseo
181 New Member
@zepphead80
thank you
the error I get is run-time error 3021 No current record
in this problem I should to set filter and Docmd.showallre cords It's intended to remove a filter, if we can handle the showallrecords if the record found that will solve the whole problem, I still think about this problem, because it is the first time I use this method (showallrecords )
so, I used this till I know if I can do it using the previous approach
Expand|Select|Wrap|Line Numbers
  1. If Not IsNull(Me.cboJob_id) Then
  2.         strWhere = strWhere & " AND " & "tbl_jobs.[Job_id] = '" & Me.cbojob_id & "'"
  3.     end if
this works great with beforeupdate trigger
thank you very much
I really appreciate your dedication
Jul 13 '10 #9
patjones
931 Recognized Expert Contributor
I would probably rewrite your code slightly and make use of recordset processing. I can show you what I would do...can you just let me know what column in your table holds job ID information, i.e. what is the column name? Thanks.

Pat
Jul 13 '10 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

3
10722
by: Radhakrishnans | last post by:
Is there a way to edit a html table row by clicking one of the button in one of the in the table.i want the cell values separately out in text box.after modifying and submitting the values it must be modified in the table.How?help me
2
1502
by: TELO | last post by:
Hi, I would like to create form to show Master & Details format. Basically show Master details on the top and related information underneath. In Access I've created similar screen by using Main form and sub form. As I know there isn't such a facility in VB.NET. From my search I found I could use datagrid, but I would like to allow users to add, edit & delete. I prefer to have something like Access Main & sub form format. Is there any...
3
14584
by: Kevin Frey | last post by:
Hello. I asked this question a while back and got no response, so I thought I'd have another shot. When I display a list of records in a GridView, I want to be able to vary the presence of the Edit and Delete buttons per row depending on eg. the user's security permissions for that row, or attributes associated with the record (eg. a purchase order that has been dispatched to a supplier cannot be deleted). Can anyone tell me the...
0
658
by: ganesh22 | last post by:
Sir: How to edit or delete xml document in webpage Using C#
1
1179
by: haringmunti | last post by:
hi, how do you add, edit or delete item using vb.net? sad to say, all i know how to do at the moment is pick the command button from the toolbox and then label it properly. im trying to make a program that allows you to update information, edit it at a later time and even delete this if this is no longer needed. i will really be grateful is someone could show me an example so i can understand how it is done and incorporate it with...
0
913
by: jm | last post by:
I have a gridview. Can the edit and delete links be denied and allowed by user? Thank you.
4
4411
by: barkarlo | last post by:
I use check box in a form "frmworkorder" like confirmation that's record finish. How can I write code who will block edit and delete record in form when is check box confirmed.
5
2600
daoxx
by: daoxx | last post by:
Hi I didn't find anything with the search - the words are too general. How can I create a macro and define what it does from code? EDIT: The other question was To do this use DoCmd.DeleteObject acForm, name Thanks
1
2045
by: fishjelly | last post by:
How to edit and delete the data stored in xml file using C# and visual studio 2005 through user input? For example: for this xml document... <MenuRoot> <Books> <book> <title> ABC </title> <author>DEF</author>
0
1726
by: =?Utf-8?B?TWVlbWEgSnVkeQ==?= | last post by:
I have a Verizon Palm Treo 755p and use Outlook 2002 on my new HP Pavilion (Vista 64-bit). When I was syncing on my old XP PC, everything worked fine. On the Vista PC, when I finally got it to sync (using a Bluetooth USB adapter), I ended up with recurring appointments that act wierd when I try to delete, move or edit them. It won't allow any of these changes, saying various messages: 1) If I try to open the recurring appointment: ...
0
8704
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9307
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9170
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9071
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6627
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5943
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4462
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3155
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2514
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.