A family of Microsoft relational database management systems designed for ease of use.
It is saving to Copy of Assets
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi guys,
OK I have been using the bundled database "Asset Tracking" to keep track of one of my collections. I have an Office 365 Home subscription. I've been successfully using this for a few months and currently have over 500 assets in the database.
As I add a new item to this database there is a field called "location". Every time I add a new location that's not already in the list it asks me if I want to add it, I say "yes", then I add it and go about my merry way.
This no longer works.
Now when I type in the new list item and hit TAB (as I've done 100 times before) when I get to the point where I click on OK it tells me again that the location is not in the list and do I want to add it?
So let's say that I just added "Belfast" it shows me the list of locations that are already in the list with Belfast at the bottom, then just above it is an entry called "B". Nothing I do will let me actually successfully add a new Location. I delete Belfast and B from the list (by dropping down the list, right clicking and select "edit list items") which does seem to delete both items, but when I go to add it again the exact same thing happens. I have a the same issue no matter which city I try to add so it's not a B or a Belfast thing.
Tech support won't help me and my database is now useless if I can't keep adding new locations to choose from when adding assets.
I've tried "Compact and Repair Database" to no avail. Tech support via chat was useless and suggested I try an online repair which just downloaded and reinstalled the program. This hasn't helped. Same problem. It seems the location field has somehow gotten corrupted.
Any help would be greatly appreciated!
A family of Microsoft relational database management systems designed for ease of use.
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
It is saving to Copy of Assets
It is saving to Copy of Assets
You're absolutely right. I figured out where it was pointing to the "copy of assets" table (the assets detail form) and changed it to save to "Assets" instead. It now seems to be working properly. Whew! THANKS!
No worries, one problems solved.
Now if you copy and paste the code I posted previously (for the module) into a new module or just put it into the 'ModMapping' module you already have and put the other few lines of code behind your not in list for each combo you will solve that too.
I modified the code for the not in list to add the title behind the combo rather than in the module code.
So.. if you highlight your locations combo on the Asset detail form, open the property form and click on the ellipses next to notinlist. Then past this exactly between the autogenerated code which will be:
Private Sub Location_NotInList(NewData As String, Response As Integer) 'Auto generated
Dim strTable As String
Dim strField As String
Dim strtitle As String
strTable = "locations"
strField = "location"
strtitle = "This Location was not found"
Response = comboboxAdd(NewData, strTable, strField, strtitle)
End sub 'Auto generated
Then, in your 'ModMapping'module paste the following exactly as it is.
'Add new to combo list
Public Function comboboxAdd(NewData As String, _
strTable As String, strField As String, strtitle As String) _
As Integer
Dim rs As DAO.Recordset
Dim StrSql As String
Dim StrMessage As String
Dim intResponse As Integer
'Set up message box to confirm
StrMessage = "'" & NewData & "' was not found " & _
Chr(10) & "Do you want to add this to the list?"
' strtitle = "Surname not Found"
If MsgBox(StrMessage, vbYesNo + vbInformation, strtitle) = vbYes Then
Set rs = CurrentDb.OpenRecordset(strTable, dbOpenDynaset)
rs.AddNew
rs.Fields(strField) = NewData
rs.Update
intResponse = acDataErrAdded
' Clean up
rs.Close
Set rs = Nothing
Else
' response is no, so show list for another selection
intResponse = acDataErrContinue
End If
comboboxAdd = intResponse
End Function
There are a lot of other things that should be modified but try this first.
oh, and two words for you BACKUP first
Hi DennisWelch.
The code you are showing is for the main category combo not in list.
You need to highlight the location combo as you have done, then on the property sheet go to the not in list event, click on the ellipses to open vba editor which will add 'private sub cboLocation_notInList etc etc.
You then add the code as you have for the category not in list. You will have to make some changes to the code though to insert into the correct table i.e. location table.
I don't normally do it that way.
If you add the following function you can then use it for all combo's (on the main access menu, click create, then 'module'. copy and paste this code to the module
'Add New item to Combo
Public Function combobox(NewData As String, _
strTable As String, strField As String, StrMsgMessage As String, StrMsgTitle As String) _
As Integer
Dim rs As DAO.Recordset
Dim strSQl As String
Dim intResponse As Integer
'Set up message box to confirm
If MsgBox(StrMsgMessage, vbYesNo + vbInformation, StrMsgTitle) = vbYes Then
Set rs = CurrentDb.OpenRecordset(strTable, dbOpenDynaset)
rs.AddNew
rs.Fields(strField) = NewData
rs.Update
intResponse = acDataErrAdded
' Clean up
rs.Close
Set rs = Nothing
Else
' response is no, so show list for another selection
intResponse = acDataErrContinue
End If
combobox = intResponse
End Function
then for each combo, click on the not in list event, ellipses, open vba editor (as you have previously) and add:
Private Sub cboEmpRank_NotInList(NewData As String, Response As Integer) 'this will be added automatically
Dim strTable As String
Dim strField As String
strTable = "tblRank" 'change "tblRank" to your table name for the combo
strField = "Rank" 'Change "Rank" to your field name
Response = combobox(NewData, strTable, strField)
End Sub 'also added automatically
OK so I created a module following your instructions and now when I click on open in the left column of my table I get the Macro error 2950 like before. Also if I click on "New Asset" I get a compile error. I didn't edit any of my forms or tables, I simply created a new module. I didn't compile anything, just copied and pasted your code into a new module and named it "AddNewAsset". Then exited VBA, went to my database and tried clicking "New Asset" and I get this:
So how do I resolve this issue? How does simply creating a new module mess everything up so bad if I haven't edited my form to even use the module? It should be obvious that I don'tknow what I'm doing and need more detailed instructions.
And YES, I created a BACKUP before doing any of this! LOL!
Edit: So I renamed my corrupted database, then renamed the backup I made this morning and am using that. The errors went away, so it's obvious that creating a module as you described is causing the issues. I'm also getting (with my current working database) a message stating "Security Warning: some active content has been disabled". I never got this before. I haven't tried clicking on "enable content" yet.