Modules & VBA :: New Record Error When No Record Exist
Dec 12, 2014
What I've done is setfocus from another subform to this subform, and I want to add a new record. I've got my code mixed up somewhere along the line as it's saying "the command or action 'RecordsGoToNew isn't available now.I'm trying to setfocus to this form, create a new record and setfocus to a field within the focussed form.
The code I'm currently using is...
Forms!frmtopline!frmTopLineSub.SetFocus
RunCommand acCmdRecordsGoToNew
Forms!frmtopline!frmTopLineSub.Form!TransactionDat e.SetFocus
View Replies
ADVERTISEMENT
Jun 9, 2015
I currently have this set as the forms default recordsource (which works just fine):
Code:
SELECT TOP 5 tblUsers_Phone_Book.EMAIL_ADDRESS, weightedDL('me@mine.com',[EMAIL_ADDRESS]) AS Expr1
And I have this vba to dynamically switch around that email address.
Code:
Private Sub Form_Load()
Dim intPos As Integer
Dim strControlName As String
Dim strValue As String
Dim sSQL As String
If Len(Me.OpenArgs) > 0 Then
' Position of the pipe
[Code] ....
If I msgbox the sSQL - it shows identical to the default recordsource but I get the error:
The error message I get is:
Run-Time error '2580'
The record source 'SELECT TOP 5 tblUsers_Phone_Book.EMAIL_ADDRESS, weightedDL('me@mine.com',[EMAIL_ADDRESS]) AS Expr1' specified on this form or report does not exist.
I tried copying the exact working default sql into the vba and get the same result.
View 3 Replies
View Related
Oct 28, 2014
I have a problem with my database I have a combo box that will search for my record. Actually its working I input the specific number it goes to the specific record. But I want, if there no existing record in my database it will display a Messagebox that "No record Found" I try to put a code in a macro builder in a after update property field but nothing happened.
Expression code that it will display the msgbox if there's no record found.
the given code from macro builder is attached. I try to have an if else statement but I dont know how to not equal that giver conditional expression.
View 10 Replies
View Related
Nov 27, 2007
I would like help with a macro that looks to see if a record in my database table exists, then if it doesn't it adds a record with my data, but if the records does exist, it stops the routine and sends a message box to prompt if you want to continue with adding a new record.
The problem that I'm having is that my macro errors out when it doesn't find a record. I just want my macro to just see if a record exists or not. Then I can write my Iff statements based on whether it finds our or not. How do I just have my macro check for an record, then if it doesn't exist tell that it doesn't exist and not stop my macro. Is there some kind of IfExist() function or something?
Thanks for any help anyone can give me.
View 4 Replies
View Related
Feb 21, 2005
I'm using the following code to autofill the city and state on my form.
I can't figure out how to capture if there is no matching record in the table.
If there is no matching record, I will:
1) inform the user with a msgbox
then if the user wants
2) open a form to add the record to the table
Dim rst As DAO.Recordset
Dim db As DAO.Database
Set db = CurrentDb
Set rst = db.OpenRecordset("tblZipcodes", dbOpenTable)
rst.MoveLast
rst.MoveFirst
Do Until rst.EOF
If strZipLookup = rst!ZipCode Then
Me.txtCoCity = rst![ZipCity]
Me.cboCoSt = rst![ZipState]
End If
rst.MoveNext
Loop
rst.Close
End If
How can I capture if there is no matching record in the table?
Thanks,
Sup
View 2 Replies
View Related
Oct 7, 2004
I have set up a simplified event booking procedure, similar to the one generated by the access event manager wizard. It uses three tables, one with attendees details, one with the event details and abooking table that links the attendee ID with the Event ID.
The booking table uses commands similar to SELECT[Names + Contacts].[ID],[Names + Contacts].[Surname]FROM[Names + Contacts] to generate drop down lists of surnames and events so that the two can be matched together.
This works fine as a table.
However when placed into a form, whenever the form is opened I get an error message saying the record source specified on the form does not exist.
I have tried regenerating the form, etc. I have used a wizard to generate the form, closed the form, not changed anything in the database and then tried reopening it and I get the error message, can anyone shed any light?
Also if you accept the message then it knows how many records there are, so it must know there's something behind it, also if you change to design mode and then back to form mode, it finds all the data.
View 4 Replies
View Related
Oct 26, 2005
I have a training database with multiple courses. Certain staff do course1 and thereafter course2. Course1 is only done once and course2 is a refresher done annually. I want the query to find staff that have done course2 but not course1.
Thanks.
View 3 Replies
View Related
Aug 6, 2005
Hi,
I'm trying to have a button on a form that would delete a record from a table only if there are no child records linked to it.
If there are child records for the selected record, the button would be disabled.
Is there a simple way of doing this?
TIA.
View 3 Replies
View Related
Feb 12, 2007
Afternoon.
I have had a search through the forum however am unable to find anything...
I have two questions:
a) How do I check whether someone else is currently accessing a record / form?
i.e. Opening the form (SchemeDetails) like this:
DoCmd.OpenForm "SchemeDetails", acNormal, "", "", acEdit, acNormal
Forms!SchemeDetails.SetFocus
DoCmd.GoToRecord acForm, "SchemeDetails", acGoTo, tempVal
Can I check if someone else is in the specified record before I open it? Record Locking is (deliberately) set to "No Locks".
b) How do I check to see if a table exists?
i.e. If DataTable2.Exists = True then ...
Or something like this?
Hope someone can help me!
View 6 Replies
View Related
Feb 19, 2008
I have a table that is filled based on selections that a user makes in combo boxes on a form. I am having trouble trying to figure out the best way to prevent duplicates from being inserted in the table when I do the append query part.
Since the table is filled based on the various selections the user makes I dont have a primary key or unique field.
Can someone help me figure out the best way to do this append/update queries to prevent duplicates. Also if you have a strategy for setting up some sort of unique or primary key for fields that could all be the same yet in the table only 1 record will show, no duplicates.
View 1 Replies
View Related
May 3, 2014
I'm getting error 2391 field 'f1' doesn't exist in destination table
Code:
Dim FileBrowse As Office.FileDialog
Dim varFile As Variant
Dim sFile As String
Set FileBrowse = Application.FileDialog(msoFileDialogFilePicker)
[Code] ....
View 1 Replies
View Related
Aug 21, 2012
I have an application written in Access 2007 and packaged using the Packaging Solutions for deployment with Runtime.My problem is that I've written an updated version, and after carefully saving my original Back End away from the install site, uninstalling Runtime and the FE, installing the new FE with a blank copy of the BE having the same name and Runtime, and copying the filled BE into the same folder with the FE (replacing the linked, but empty, BE) I find that SOME of my tables in the BE are not being recognized. This isn't true of all tables. I can open some of the forms and find everything there. In other cases I get the following error message "The record source "tblName" specified on this form or report does not exist."
View 2 Replies
View Related
Jan 23, 2014
I have a small database with several forms. One of them has a command button to open a new form (which also contains a continuous subform) and go to a new record in the form. This is the code behind it:
Code:
stDocName = "Main Data Entry"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.RunCommand acCmdRecordsGoToNew
This database has been in use for quite without problems a while but now I am doing a few small changes and cleaning it up of data to start over.The code above gives the error "The command or action "RecordsGoToNew" isn't available now" yet it opens the form just fine and data can be entered. This error only happens when the first record is entered; it does not show up when entering the second or subsequent records.
View 8 Replies
View Related
Sep 18, 2014
I get this error when I delete more than one record consecutively.
Here is my delete code;
Private Sub Komut98_Click()
Dim blnLast As Boolean
'MsgBox call must return the value in order to be checked.
'If user says no then cancelling is not required. It is only required
' that the deletion command is not invoked.
[Code] ....
View 5 Replies
View Related
Aug 25, 2013
I want to add a record with attachment to a table in an access (2013) database.
If I ignore the attachment error everything works as it should, but as soon as I add the code for the attachment I receive error code 3259.
Code:
Private Sub add_tune()
Dim dbtune As DAO.Database
Dim rst_tune As DAO.Recordset
Dim rst_tune_in As DAO.Recordset
Dim rs_child As DAO.Recordset
Set dbtune = CurrentDb
[code]....
Since I have a dutch office version the error text (ongeldig veld gegevenstype) is in dutch, translated it means something like a data type mismatch.
t_first_bars is a field in the table tbl_tune . The field type is attachment.
View 6 Replies
View Related
Feb 26, 2015
I have an unbound form: frm_ReceiptSearch with some fields that, when something is input, will search a datasheet viewed form on a subform on the main form (subform name is sf_frm_Receipts). Currently, on the txt_CheckNo field's after update event, I have the following code:
Private Sub txt_CheckNo_AfterUpdate()
Dim SrchVar As String
SrchVar = Me.txt_CheckNo
Me!sf_frm_Receipts!REFNO.SetFocus
DoCmd.FindRecord SrchVar, acEntire, , acSearchAll, , acCurrent, True
End Sub
but I'm getting a runtime error 438.
View 4 Replies
View Related
Jan 3, 2014
How to by pass error 3021 No current record
I know I can put the code below just don't know where to put it.
If Err.Description = "No current record" Then Resume
I attached a pic of my code that is causing the error .. and its okay I just want to by pass the message box.
View 4 Replies
View Related
Jul 25, 2013
I need to be able to produce an error on a form where the user attempts to create a new user that already exists. The error needs to be produced when the save button is clicked.
See below for the existing code on my save button which exists in form, 'frmAddEditUser':
Private Sub cmdSave_Click()
If IsNull(cboManagerID) = True Then
MsgBox "Please select a manager", vbExclamation, "Details Missing!"
Me.cboManagerID.Requery
[Code] ....
Currently, if I attempt to create a user with the same Payroll ID as an existing user, my 'User details saved' message box is displayed and to the user it looks like a new record has saved successfully which isn't the case.
I need a message box to appear displaying something like "Payroll ID n already exists" where n is the 'PayrollID' of the duplicate record. (Is it possible to combine a value from a certain control and ones own custom text?)
Note: PayrollID is a combination of letters and numbers, i.e. two letters, followed by 5 numbers, e.g. JD12345.
For reference, the table/field and and control are called, '[tblUser].[PayrollID]' and 'txtPayrollID' (on 'frmAddEditUser') respectively; it is from this field and control that I want the error to be produced if the user is entering the same values which are existing in 'tblUser'.
View 10 Replies
View Related
Sep 25, 2014
The below SQL is basically trying move a record from one table to another, the table a copies of one another and the AlphaName variable is a string.
I keep getting the incomplete query error, somethings missing but what.
Code:
strSQL = "INSERT INTO [Holding Table].* SELECT ([Import Table].* FROM [Import Table]
WHERE ([Import Table].[Alpha Name] = '" & AlphaName & "'));"
View 3 Replies
View Related
Mar 13, 2014
I have some code that will run if I am populating an empty table(no duplication's possible) but now I am trying to create a Sub to check for existence of a record and handling it going forward.
Anyways the big picture is looping through a text file and placing data where it needs to go. The code follows including some comments point to the issue.
Code:
Sub PutinNewTag(TableIn As String, Tagtype As String, textline As String)
Dim strSQL As String
Dim NameIn As String
Dim TagName As String
Dim Db As DAO.Database
Dim rstin As DAO.Recordset
[Code] ....
View 8 Replies
View Related
Jun 16, 2014
I have a linked table to a DB2 database. this table contains key-pair values and has about 140k records.
I use a Sub to update the value of a specific record.
The sub starts by opening the needed DAO recordset
Then it uses the rs.Findfirst method
It checks if rs.Nomatch is not true (so the records exists!)
Then it starts updating the record with
rs.edit
rs!value1 = myvalue1,
rs!value2 = myvalue 2
rs.Update
There is where I get the '3021 No current record' error
I use the same sub on the same table to update to different parts. One part works the other gives me the error.
I have checked for typos.
View 5 Replies
View Related
Jun 28, 2013
When we browse through records in a subform we store the records in the database.When we want to delete a records for example the third record from the five records always the first records will be deleted. How can we delete the records where the cursor is at? When we are at the third record and press the delete button the third record from the list in the subform should be deleted.
Code:
Option Compare Database
Dim FocusBln As Boolean
Private Sub Identificeer()
Me.[Datum Aangemaakt].Visible = True
Me.[Datum Aangemaakt].SetFocus
If Me.[Datum Aangemaakt].Text = "" Then
[code]...
View 11 Replies
View Related
Jan 26, 2015
i want to be able to create an On Click Event when pushing a command button that will run an Update query to update a record and after it has been updated that specific record will pop up on a Form and be displayed. i know a different way is to run the Update query and then have it displayed in a Select query but i want it to be displayed on a Form instead. is it possible?
View 4 Replies
View Related
Aug 19, 2013
I have two forms both with separate tables
(1) Register and
(2) Payments.
One of the common denominators between them is the URN which is auto-populated as it is an auto number field. My issue is that when I want to add a new record to the payments table using the forms (I can get to the payments form via the register form), I want to be able to identify the record that I am currently viewing within the register and auto populate the URN field with the same number. This is what I have done so far,
Option Compare Database
Option Explicit
Private Sub AttachPaymentDetails()
Call PerformInsert("tblFinancialBudget", "frmFinancialBudget")
End Sub
[code]....
View 5 Replies
View Related
Oct 23, 2014
I would like to highlight record when user will click Record Selector in the continuous form. How to do it?
View 1 Replies
View Related
Sep 8, 2013
I have a form set to the table Client Information with a subform set to the table Event Information. Client Information has a one to many relationship to Event Information.
There is a button that deletes the current record in Client Information--also deleting the related records in Event Information--then closes the form. The code works fine but a blank record in Event Information is apparently being created before the form closes.
Here's the VBA that I'm using:
Private Sub CmdDelReturn_Click()
Dim CmdDelReturnMsg As String
CmdDelReturnMsg = MsgBox("Delete event & client then return to front?", vbYesNo + vbDefaultButton1, "Delete and Return?")
[Code] ....
It's not a big deal because the button won't be used often and I can manually go into the table to delete the blank record. But if there's a simple solution to prevent this that would be nice.
View 3 Replies
View Related