Hi All,
Im trying to finish off some coursework im doing. Ive finished the database, created all my forms and everything works perfectly, that was until i created a switchboard!!!
Im using the following code to notify users that when they enter an artist's name (im building a cd database) a message pops up and tells them the artist is already created and then takes them to the relevant record. It works perfectly if i just open the form, but when i open through the switchboard it bugs out!! Can anyone help? The line in bold is where it errors.
Private Sub Artist_Nme_BeforeUpdate(Cancel As Integer)
Dim ArtistID As String
Dim stLinkCriteria As String
Dim rsc As DAO.Recordset
Set rsc = Me.RecordsetClone
ArtistID = Me.[Artist Nme].Value
stLinkCriteria = "[Artist Nme]=" & "'" & ArtistID & "'"
'Check Artist table for duplicate Artist Name
If DCount("[Artist Nme]", "Artist", stLinkCriteria) > 0 Then
'Undo duplicate entry
Me.Undo
'Message box warning of duplication
MsgBox "Warning Artist " _
& ArtistID & " has already been entered." _
& vbCr & vbCr & "You will now been taken to the record.", vbInformation _
, "Duplicate Information"
'Go to record of original Student Number
rsc.FindFirst stLinkCriteria Me.Bookmark = rsc.Bookmark
End If
Set rsc = Nothing
End Sub
Thanks for your help!
Paul
5 6139
'Undo duplicate entry
Me.Undo
You have undone your entry therefore the Criteria is no longer valid. There is no artist on the form to compar to.
Hi All,
Im trying to finish off some coursework im doing. Ive finished the database, created all my forms and everything works perfectly, that was until i created a switchboard!!!
Im using the following code to notify users that when they enter an artist's name (im building a cd database) a message pops up and tells them the artist is already created and then takes them to the relevant record. It works perfectly if i just open the form, but when i open through the switchboard it bugs out!! Can anyone help? The line in bold is where it errors.
Private Sub Artist_Nme_BeforeUpdate(Cancel As Integer)
Dim ArtistID As String
Dim stLinkCriteria As String
Dim rsc As DAO.Recordset
Set rsc = Me.RecordsetClone
ArtistID = Me.[Artist Nme].Value
stLinkCriteria = "[Artist Nme]=" & "'" & ArtistID & "'"
'Check Artist table for duplicate Artist Name
If DCount("[Artist Nme]", "Artist", stLinkCriteria) > 0 Then
'Undo duplicate entry
Me.Undo
'Message box warning of duplication
MsgBox "Warning Artist " _
& ArtistID & " has already been entered." _
& vbCr & vbCr & "You will now been taken to the record.", vbInformation _
, "Duplicate Information"
'Go to record of original Student Number
rsc.FindFirst stLinkCriteria Me.Bookmark = rsc.Bookmark
End If
Set rsc = Nothing
End Sub
Thanks for your help!
Paul
Hi,
Thanks for the quick reply. Ive tried removong that line before but i still get the same error.
The theory behind using that line (Im by no way an expert) is that i want to undo the data ive just put into that field, and remove the record ive just tried to create, as im bringing back existing data from the table.
Cant seem to get it to work, but its only happening when opening the form through the switchboard.
Cheers
Paul
What exactly is the error message you are getting?
Hi,
Thanks for the quick reply. Ive tried removong that line before but i still get the same error.
The theory behind using that line (Im by no way an expert) is that i want to undo the data ive just put into that field, and remove the record ive just tried to create, as im bringing back existing data from the table.
Cant seem to get it to work, but its only happening when opening the form through the switchboard.
Cheers
Paul
The Error message is
Run-time error '3021';
No current record
Just a thought, would it be to do with the fact im opening the for in 'Add Mode'??
Cheers
Once you undo a record you no longer have any values so anything that uses the Me. reference won't see the intended value. Put these values into variables before you undo and use the variables to reference your code thereafter.
The Error message is
Run-time error '3021';
No current record
Just a thought, would it be to do with the fact im opening the for in 'Add Mode'??
Cheers
Sign in to post your reply or Sign up for a free account.
Similar topics
by: PDR |
last post by:
Help for a ASP newby. Can anyone help me with a very basic problem. I would
like to learn about this ASP stuff. I know a little of HTML and hev built a
few web pages but I would like to know about...
|
by: James Leech |
last post by:
Hi guys
I am trying to use an Access function that I found on the web from within an
asp page, but I can't seem to correct all the subtle differances between the
two languages. When I run a...
|
by: Jill |
last post by:
I am trying to store the current date to an ms access database on my server.
I set it up with a dsnless connection.
Here is the statement:
Insert Into employees(timestamp) Values ('" & date() &...
|
by: Grasshopper |
last post by:
Hi,
I am automating Access reports to PDF using PDF Writer 6.0. I've
created a DTS package to run the reports and schedule a job to run this
DTS package. If I PC Anywhere into the server on...
|
by: google |
last post by:
I'm trying to implement something that would speed up data entry. I'd
like to be able to take a string, and increment ONLY the right-most
numerical characters by one. The type structure of the...
|
by: Adam Turner via AccessMonster.com |
last post by:
If I had a field called "Name" in an Access table "Contact Info", and the
field contained VBScript...
Function Main(rstFields)
Main = rstFields.Item("FirstName").Value
End Function
1. How do...
|
by: Aws |
last post by:
My crazy GridView !!
I am using Visual Studio 2005, I have a problem with my GridView.
I have one access .mdb table and when I update a record on the table
EVERYTHING is perfect. I made a Web...
|
by: JNariss |
last post by:
Hello,
I have created a connection to my Access database with Dreamweaver and
made a simple form with 4 fields.
The code behind this form was/is:
<%@LANGUAGE="VBCRIPT" CODEPAGE="1252"%>...
|
by: David |
last post by:
Hi,
I cannot get the following (MS Access) SQL statement working in my asp
page, please can anyone help me ? Thanks :-)
------------------------------------------------
<%
strQuery =...
|
by: Andrew Wan |
last post by:
How can VBScript code access JScript code variables in the same ASP page?
<SCRIPT LANGAUGE="VBScript">
Dim a
a = 10
</SCRIPT>
<SCRIPT LANGUAGE="JScript">
Response.Write(a);
</SCRIPT>
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |