dao recordset updating the wrong record - recordset

I'm trying to have a form usable for both creating a new record or updating another. Currently it is doing it through the value of a textbox (new or edit). The structure works fine, but for some reason, when it is performing the edit function, it is saving changes to the wrong record. For instance, if I am editing record 1027, when i submit it, it'll update record 1073. Its consistent, it'll always update the same, wrong record. Edit 1000, it'll update 1073; if i update 1081, it'll update 1073, and so on. Is there a way to specify which record it should be editing? yes, the record number is the primary key/id. Heres the code:
Private Sub btnSubmit_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strTable As String
Dim strField As String
Dim ID As Long
Dim newID As Long
strTable = "record_holdData"
Set db = CurrentDb
Set rs = db.OpenRecordset(strTable)
'button has 2 modes
If txtMode.Value = "NEW" Then
With rs
.AddNew
.Fields("PO_no") = txtPONum
.Fields("prodSupervisor") = cboProdSup
.Fields("qaSupervisor") = cboQASup
.Fields("labTech") = cboLabTech
.Fields("flavor") = cboFlavor
.Fields("lineNumber") = cboLineNumber
.Fields("container") = cboContainer
.Fields("package") = cboPackage
.Fields("holdQty") = txtQty
.Fields("productionDate") = txtProdDate
.Fields("dateCode") = txtDatecode
.Fields("component") = cboComponent
.Fields("nonconformance") = cboDiscrepancy
.Fields("foundDuring") = cboFoundAt
.Fields("responsibility") = cboRespCode
.Fields("comments") = txtDescription
.Fields("rootCause") = txtRootCause
.Fields("holdStatus") = 1
.Fields("dateOpened") = Now()
.Update
.Bookmark = .LastModified
newID = !ID
End With
MsgBox ("Hold information saved!")
btnPrintTag.Enabled = True
DoCmd.OpenReport "Holdtag", acViewPreview, , "[ID] = " & newID
DoCmd.Close
ElseIf txtMode.Value = "EDIT" Then
'do editing stuff
With rs
.Edit
.Fields("PO_no") = txtPONum
.Fields("prodSupervisor") = cboProdSup
.Fields("qaSupervisor") = cboQASup
.Fields("labTech") = cboLabTech
.Fields("flavor") = cboFlavor
.Fields("lineNumber") = cboLineNumber
.Fields("container") = cboContainer
.Fields("package") = cboPackage
.Fields("holdQty") = txtQty
.Fields("productionDate") = txtProdDate
.Fields("dateCode") = txtDatecode
.Fields("component") = cboComponent
.Fields("nonconformance") = cboDiscrepancy
.Fields("foundDuring") = cboFoundAt
.Fields("responsibility") = cboRespCode
.Fields("comments") = txtDescription
.Fields("rootCause") = txtRootCause
.Fields("lastEditDate") = Now()
.Update
End With
MsgBox ("Information Updated")
End If
End Sub

Sorry i caught it. Problem was I was basically redefining the recordset each time the subroutine was called. I changed the second block to the following:
ElseIf txtMode.Value = "EDIT" Then
'do editing stuff
Set rs = db.OpenRecordset("SELECT * FROM record_holdData WHERE ID=" & txtID)
With rs
.Edit
.Fields("PO_no") = txtPONum
.Fields("prodSupervisor") = cboProdSup
.Fields("qaSupervisor") = cboQASup
.Fields("labTech") = cboLabTech
.Fields("flavor") = cboFlavor
.Fields("lineNumber") = cboLineNumber
.Fields("container") = cboContainer
.Fields("package") = cboPackage
.Fields("holdQty") = txtQty
.Fields("productionDate") = txtProdDate
.Fields("dateCode") = txtDatecode
.Fields("component") = cboComponent
.Fields("nonconformance") = cboDiscrepancy
.Fields("foundDuring") = cboFoundAt
.Fields("responsibility") = cboRespCode
.Fields("comments") = txtDescription
.Fields("rootCause") = txtRootCause
.Fields("lastEditDate") = Now()
.Update
End With

Related

TYPO3 Show fe_user with Hyperlink and GET parameter

I'm using TYPO3 7.6 and I'd like to send an email with a Hyperlink to my TYPO3-Website (page=123). On this page I've listed all fe_users with the following TypoScript, but I'll only show one specific user, f.e. uid=20.
I have two questions:
How can I show only this user (uid) on my page?
How do I call my hyperlink?
Show all users:
lib.feUserLink = CONTENT
lib.feUserLink {
table = fe_users
select.pidInList = 10
select.max = 10
select.orderBy = last_name DESC
where = disable = 0
renderObj = COA
renderObj {
10 = TEXT
10.field = first_name
10.wrap = wq<p><strong>|
...
14 = TEXT
14.field = email
14.wrap = |</p>
}
}
-> 1. Then I have to edit my WHEREclause, but i dont't know how? All of my tests won't work.
lib.feUserLink = CONTENT
lib.feUserLink {
table = fe_users
...
andWhere.dataWrap = uid={GP:fe_users|uid}
#andWhere.data = GP:feuseruid
#andWhere.data = GP:fe_user|uid
#andWhere.intval = 1
#andWhere.wrap = uid=|
...
-> 2. And how can I show only the User from the GET-Parameter?
http://my.domain.tld/index.php?id=123&uid=20
http://my.domain.tld/index.php?id=123&feuser=20
http://my.domain.tld/index.php?id=123&fe_users[uid]=20
...
I hope someone can give me a crucial tip ...
... thank you.
Regards
Stefan
my solution was
lib.feuserLink = CONTENT
lib.feUserLink {
table = fe_users
select {
pidInList = 10
orderBy = last_name DESC
where = uid = ###field_uid###
markers.field_uid.data = GP:user
markers.field_uid.intval = 1
max = 1
}
...
Thanks for helping ...
2) Build link to page 123 with uid parameter from fe_user. Adds something like
?id=123&user=456&cHash=789
lib.feUserLink = CONTENT
lib.feUserLink {
table = fe_users
select {
pidInList = 10
max = 10
orderBy = last_name DESC
}
renderObj = COA
renderObj {
10 = TEXT
10.field = username
10.typolink {
parameter = 123
additionalParams.dataWrap = &user={field:uid}
useCacheHash = 1
}
10.wrap = |</br>
}
}
1) To show only selected user in given list, adapt your select like
[globalVar = GP:user > 0]
lib.feUserLink.select {
where = uid = ###field_uid###
markers.field_uid.data = GP:user
markers.field_uid.intval = 1
max = 1
}
[global]
You don't need clause where = disable = 0. Its already included in the SQL query by default.

IE11 clears password fields on page refresh:

Happens only in IE (Chrome and Firefox, no issues... go figure)
I have a page where customer's can update their details (name, address,password etc.) and everything is working fine, however if the customer submits the form (which also works fine) and then presses the back button all the customer's information will repopulate the form except for the password field.
My boss would like this to repopulate as well, like it does in Chrome and Firefox, but IE won't do it. I'm hoping it's something simple I've missed but I can't see it. I've tried adjusting the lines where the text fields are populated to match the rest of the form, but that just results in empty fields. Code below.
Page_Load
If TypeOf Session("Customer") Is GPCUser Then
c = CType(Session("Customer"), GPCUser)
Else
Response.Redirect("default.aspx")
End If
If Not Page.IsPostBack Then
If c.CustomerID > 0 Then
'populate the table
lblAccountName.Text = c.AccountName
txtFirstName.Text = c.FirstName
txtLastName.Text = c.LastName
txtEmail.Text = c.Email
txtAddress.Text = c.Address
txtSuburb.Text = c.Suburb
txtCityTown.Text = c.City
txtPostcode.Text = c.PostCode
txtPhone.Text = c.Phone
txtMobile.Text = c.Mobile
'chkNewsletter.checked = c.Newsletter
txtPassword.Attributes.Add("value", c.GeneratedPassword)
txtConfirmPassword.Attributes.Add("value", c.GeneratedPassword)
'txtPassword.Text = c.GeneratedPassword
'txtConfirmPassword.Text = c.GeneratedPassword
Dim subscriptions As ContactSubscriptions = New ContactSubscriptions(c.CustomerID)
chkGenernalNewsletters.Checked = subscriptions.IsGenernalNewsletters
End If
Else
End If
Update Button
If TypeOf Session("Customer") Is GPCUser Then
c = CType(Session("Customer"), GPCUser)
Else
Exit Sub
End If
c.AccountName = lblAccountName.Text
c.FirstName = txtFirstName.Text
c.LastName = txtLastName.Text
c.Email = txtEmail.Text
c.Address = txtAddress.Text
c.Suburb = txtSuburb.Text
c.City = txtCityTown.Text
c.PostCode = txtPostcode.Text
c.Phone = txtPhone.Text
c.Mobile = txtMobile.Text
'c.Newsletter = chkNewsletter.Checked
c.GeneratedPassword = txtPassword.Text
c.CustomerUpdatedRequired = false
'Update password field
txtPassword.Attributes.Add("value", c.GeneratedPassword)
txtConfirmPassword.Attributes.Add("value", c.GeneratedPassword)
GPCUser.AddUpdateCustomer(c)
subscriptions.IsGenernalNewsletters = chkGenernalNewsletters.Checked
subscriptions.Save()
Session("Customer") = c
lblMessage.Text = "Your details have been successfully updated."
pnlUpdateAccount.Visible = False

How to check whether there is claim identity exist in the URL

My purpose for this feature is to check whether there is 2 or 3...URLs hide within 1 URL, if yes then return 1, else return 0. e.g. www.applee.com/www.samsunge.com, http://www.samsungds.http://comwww.samsung.com
I have settled the importdata prob, but now I faced difficulty for checking the data below:(I have modify the 'is_double_url.m' file, but it return me the error)
http://encuestanavemotors.com.ar/doc/newgoogledoc2013/2013gdocs/
http://totalwhiteboard.com.au/.pp/0053d4ae3e2c78154d29d413c1236341/192.186.237.145/H/
http://www.wwwwwwwwwws2.com/
http://www.paypal.com.cy.cgi.bin.webscr.cmd.login.submit.dispatch.5885d80a1faee8d48a116ba977951b3435308b8c4.turningpoint.in/f044c94b4394939f4a1a75798875f78c/
http://www.celebramania.cl/web/cc/personal/cards/5d0d5c5af4f12c319d47872fabe11262/Pool=0/?cmd=_home&dispatch=5885d80a13c0db1f8e&ee=5cd428ee24c5037dda298a4762735a94
http://joannalindsay.com/wp-content/uploads/aloo/aaleor.php?bidderblocklogin&hc=1&hm=uk%601d72f%2Bj2b2vi%3C265bidderblocklogin&hc=1&hm=uk%601d72f%2Bj2b2vi%3C265bidderblocklogin&hc=1&hm=uk%601d72f%2Bj2b2vi%3C265
http://bluedominoes.com/~kosalbco/paypal.de/
is_double_url.m file
function out = is_double_url(url_path1)
f1 = strfind(url_path1,'www.');
if isempty(f1)
out = 0;
return;
end
f2 = strfind(url_path1,'/');
f3 = bsxfun(#minus,f2,f1');
count_dots = zeros(size(f3,1),1);
for k = 1:size(f3,1)
[x,y] = find(f3(k,:)>0,1);
str2 = url_path1(f1(k):f2(y));
if ~isempty(strfind(str2,'..'))
continue
end
count_dots(k) = nnz(strfind(str2,'.'));
end
out = ~any(count_dots(2:end)<2);
if any(strfind(url_path1,'://')>f2(1))
out = true;
end
return;
f10.m file
data = importdata('url');
[sizeData b] = size(data);
for i = 1:sizeData
feature10(i) = is_double_url(data{i});
end
Code
function out = is_double_url(url_path1)
if url_path1(end)~='/'
url_path1(end+1)='/';
end
url_path1 = regexprep(url_path1,'//','//www.');
url_path1 = regexprep(url_path1,'//www.www.','//www.');
f1 = strfind(url_path1,'www.');
if numel(f1)<2
out = false;
else
f2 = strfind(url_path1,'/');
f3 = bsxfun(#minus,f2,f1');
count_dots = zeros(size(f3,1),1);
for k = 1:size(f3,1)
[~,y] = find(f3(k,:)>0,1);
str2 = url_path1(f1(k):f2(y));
if ~isempty(strfind(str2,'..'))
continue
end
count_dots(k) = nnz(strfind(str2,'.'));
end
out = ~any(count_dots(2:end)<2);
if any(strfind(url_path1,'://')>f2(1))
out = true;
end
end
return;
Runs
is_double_url('http://www.farthingalescorsetmakingsupplies.com/files/files/www.apple.com/')
is_double_url('http://www.farthingalescorsetmakingsupplies.com/files/files/www.com/')
is_double_url('http://www.farthingalescorsetmakingsupplies.com/files/files/https://www.com/')
is_double_url('http://www.farthingalescorsetmakingsupplies.com/files/files/https://www.dfdsf.my/')
Returns - 1 0 1 1 respectively.
If you have a list of URLs in a text file , use this to do checking for each of them -
fid = fopen('text2.txt'); %% 'text2.txt' has the urls on line by line basis
C = textscan(fid, '%s\n');
fclose(fid);
for k = 1:numel(C{1})
out(k) = is_double_url(C{1}{k}); %%// out stores the condition checked statuses
end

rally_api query for getting defects based on iteration

I am using rally_api gem in Ruby. Could any one suggest me how to write query that gets all the defects under a particular iteration?
require 'rally_api'
headers = RallyAPI::CustomHttpHeader.new()
headers.version = "1.0"
config = {:base_url => "https://rally1.rallydev.com/slm"}
config[:username] = "mvcmxb"
config[:password] = "kjkjk"
config[:workspace] = "Persons"
config[:project] = "Business he does"
config[:headers] = headers
#rally = RallyAPI::RallyRestJson.new(config)
test_query = RallyAPI::RallyQuery.new()
test_query.type = "defect"
test_query.fetch = true
results = #rally.find(test_query)
Here is a code example when defects are queried by iteration and their description is updated. You may either query by iteration name:
query.query_string = "(Iteration.Name = \"i10\")"
or iteration ref:
query.query_string="(Iteration = /iteration/13589769934)"
Names are not unique, but the query is also bound by the project:
rally = RallyAPI::RallyRestJson.new(config)
query = RallyAPI::RallyQuery.new()
query.type = :defect
query.fetch = "Name,FormattedID,Iteration,Description"
query.project = {"_ref" => "https://rally1.rallydev.com/slm/webservice/v2.0/project/12352608219.js" }
query.project_scope_up = false
query.project_scope_down = false
query.order = "Name Asc"
#query.query_string = "(Iteration.Name = \"i10\")"
query.query_string="(Iteration = /iteration/13589769934)"
results = rally.find(query)
results.each do |d|
puts "FormattedID: #{d["FormattedID"]}, Iteration: #{d["Iteration"]["Name"]}"
d.read
fieldUpdates = { "Description" => "bad defect"}
d.update(fieldUpdates)
end

Wrong Number of Arguments

I understand what causes the wrong number of arguments error but my code doesn't pass any parameters to initialize any of the classes so I'm not sure at all why my code is giving me this error. I'm also pretty new to Ruby on Rails so that doesn't help things. My code is below:
def create_google_file
#products = Product.find(:all)
file = File.new('dir.xml','w')
doc = REXML::Document.new
root = REXML::Element.new "rss"
root.add_attribute("xmlns:g", "http://base.google.com/ns/1.0")
root.add_attribute("version", "2.0")
channel = REXML::Element.new "channel"
root.add_element channel
title = REXML::Element.new "title"
title.text = "Sample Google Base"
channel.add_element title
link = REXML::Element.new "link"
link.text = "http://base.google.com/base/"
channel.add_element link
description = REXML::Element.new "description"
description.text = "Information about products"
channel.add_element description
#products.each do |y|
item = channel.add_element("item")
id = item.add_element("g:id")
id.text = y.id
title = item.add_element("title")
title.text = y.title
description = item.add_element("description")
description.text = y.description
googlecategory = item.add_element("g:google_product_category")
googlecategory.text = y.googlecategory
producttype = item.add_element("g:product_type")
producttype.text = y.producttype
link = item.add_element("link")
link.text = y.link
imglink = item.add_element("g:image_link")
imglink.text = y.imglink
condition = item.add_element("condition")
condition.text = y.condition
availability = item.add_element("g:availability")
availability.text = y.availability
price = item.add_element("g:price")
price.text = y.price "USD"
gtin = item.add_element("g:gtin")
gtin.text = y.gtin
brand = item.add_element("g:brand")
brand.text = y.brand
mpn = item.add_element("g:mpn")
mpn.text = y.mpn
expirationdate = item.add_element("g:expiration_date")
expirationdate.text = y.salepricedate
end
doc.add_element root
file.puts doc
file.close
end
The error I'm getting is:
ArgumentError in ProductsController#create_google_file
wrong number of arguments (1 for 0)
At the request of the poster, I am putting my comments in to an answer:
Based purely on the consistency of the other lines, but without knowing which line is actually failing, it may be this part: price.text = y.price "USD". Is y.price a method that takes in a parameter? Is it defined as def price(type) or something? If not, if it doesn't take any parameters, then it's because you're not supposed to send any parameters to that method. It looks like it's just a getter.
#FranklinJosephMoormann As I suspected, that's the line. Were you trying to make a string like "4.50 USD"? Then you probably wanted: price.text = "#{y.price} USD". That will take the result of y.price and put it in a string, and allow you to keep typing more in the string. It's called string interpolation.

Resources